object Main {
  def main(args: Array[String]) {
    val input = io.Source.stdin.getLines()
    println(solve(input))
  }

  def solve(input: Iterator[String]): Object = {
    val Array(n, x) = input.next().split(" ").map(_.toLong)

    def burgerSize(l: Int): Long =
      (1L << (l + 2)) - 3

    def pattySize(l: Int): Long =
      (1L << (l + 1)) - 1

    def rec(x: Long, l: Int): Long = {
      val burgerL1 = burgerSize(l - 1)
      println(s"x = $x, l = $l, burgerL1 = $burgerL1")

      if (l == 0 && x == 1)
        return 1

      if (l == 0)
        return 0

      if (x <= 1)
        return 0

      if (x + 1 <= burgerL1) {
        println("x")
        rec(x - 1, l - 1)
      } else if (burgerL1 + 2 == x) {
        println("y")
        1 + pattySize(l - 1)
      } else {
        println("z")
        1 + pattySize(l - 1) + rec(x - burgerSize(l - 1) - 2, l - 1)
      }
    }.ensuring{x => println(x); true}

    rec(x, n.toInt)
  }
}