import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]): Unit = {

    val Array(n, x) = readLine().split(' ').map(_.toLong)
    val ls: Vector[Long] = (1 to n.toInt)
      .foldLeft(Vector(1): Vector[Long])((acc, i) =>
        acc :+ (acc(i - 1) * 2 + 3))
    val ps: Vector[Long] = (1 to n.toInt)
      .foldLeft(Vector(1): Vector[Long])((acc, i) =>
        acc :+ (acc(i - 1) * 2 + 1))
    println(patty(n.toInt, x, ls, ps))

  }

  def patty(n: Int, x: Long, ls: Vector[Long], ps: Vector[Long]): Long = {

    if (x == 0) {
      0
    } else if (n == 0) {
      1
    } else if (x <= (ls(n) - 1) / 2) {
      patty(n - 1, x - 1, ls, ps)
    } else if (x == (ls(n) - 1) / 2) {
      patty(n - 1, x - 1, ls, ps) + 1
    } else {
      ps(n - 1) + 1 + patty(n - 1, x - ls(n - 1) - 2, ls, ps)
    }

  }

}
