fun main(args: Array<String>) {
    val (N, X) = listOfLong()
    val a = listOf(1L).toMutableList()
    val p = listOf(1L).toMutableList()
    for (n in 1 .. N.toInt()) {
        a.add(a[n - 1] * 2 + 3)
        p.add(p[n - 1] * 2 + 1)
    }
    fun f(n: Int, x: Long): Long {
        if (n == 0) {
            return  if (x <= 0L) 0 else 1
        } else if (x <= 1 + a[n - 1]) {
            return f(n - 1, x - 1)
        } else {
            return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1])
        }
    }
    val ans = f(N.toInt(), X)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)
