import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val x = scanner.nextLong()
    val burgerSize = arrayListOf(1L)
    val numOfPatty = arrayListOf(1L)
    for (i in 1..n) {
        burgerSize.add(burgerSize[i-1] * 2 + 3)
        numOfPatty.add(numOfPatty[i-1] * 2 + 1)
    }
    
    fun calc(n: Int, x: Long): Long {
        if (n == 0) return 1
        if (x <= n) return 0
        if (x == burgerSize[n]) return numOfPatty[n]

        val center = (burgerSize[n] + 1).div(2L)
        return when {
            x < center -> calc(n - 1, x - 1)
            x > center -> numOfPatty[n - 1] + 1 + calc(n - 1, x - burgerSize[n - 1] - 2)
            else -> numOfPatty[n - 1] + 1
        }
    }
    print(calc(n, x))
}