fun main(args:Array<String>) {
	var z=1L
	for(i in 0..50){
		size[i] = z
		z = z*2+3
	}
	
	val (n,x)= readLine()!!.split(" ").map {it.toLong()}
	println(runrun(n.toInt(),x))
}

val size = LongArray(51)

fun runrun(n:Int,x:Long): Long{
	return when(x){
		0L -> 0L
		size[n] -> 1L.shl(n+1)-1
		1L -> 0L
		in 2L..1+size[n-1] -> runrun(n-1,x-1)
		2+size[n-1] -> 1+runrun(n-1,size[n-1])
		else -> 1+runrun(n-1,size[n-1])+runrun(n-1,x-size[n-1]-2)
	}
}