import scala.io.StdIn.readLine

object Main{
  def solve(n : Int, x : Long): Long ={
    if(n == 0) x
    else{
      val hSize : Long = (1.toLong << (n + 1)) - 3
      val ps : Long = (1.toLong << n) - 1
      if(x == 0) 0
      else if(x == hSize + 2) ps + 1
      else if(x == 2 * hSize + 3) 2 * ps + 1
      else if(x > hSize + 2) ps + 1 + solve(n - 1, x - hSize - 2)
      else solve(n - 1, x - 1)
    }
  }

  def main(args : Array[String]): Unit ={
    val Array(n, x) = readLine().split(' ')
    println(solve(n.toInt, x.toLong))
  }
}
