fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(' ').map { it.toLong() }
    println(Solver(n.toInt()).solve(x))
}

class Solver(private val n: Int) {

    private val a = LongArray(n + 1) { 1L }
    private val p = LongArray(n + 1) { 1L }

    init {
        (0 until n).forEach {
            // B + L-1 Berger + P + L-1 Berger + B
            a[it + 1] = a[it] * 2 + 3
            p[it + 1] = p[it] * 2 + 1
        }
    }

    fun solve(x: Long): Long {
        return f(n, x)
    }

    private fun f(n: Int, x: Long): Long {
        if (n == 0) {
            return if (x > 0) 1 else 0
        }

        // B + L-1 Berger
        if (x <= a[n - 1] + 1) {
            return f(n - 1, x - 1)
        }

        // B + L-1 Berger + P + f(...)
        return p[n - 1] + 1 + f(n - 1, x - a[n - 1] - 2)
    }

}