object Main extends App {
  val in = io.Source.stdin.getLines.toIndexedSeq.head.split(' ').map(_.toLong)
  val N = in(0).toInt
  val X = in(1)
  //println(N, X)
  
  private def func(n:Int, x:Long):(Int, Long) = {
	//println("func", n,x)
    if(n==0 && x>0 ) return (1, 1L)
    if(n==0 && x==0) return (1, 0L)
    
    val (len, nump) = func(n-1, x)
    //println("1st", n-1, x, len, nump)
    val nextlen = 3 + 2*len
    if(x==1) return (nextlen, 0)
    if(x-1 <= len) return (nextlen, nump)
    if(len == x) return (nextlen, nump+1)
    //if(len < x)
    val (l2, p2) = func(n-1, x-len-2)
    //println("2nd", n-1, x-len-2, l2, p2)
    return (nextlen, nump + 1 + p2)
  }
  val ret = func(N, X)
  println(ret._2)
}
