"use strict";

function main(input) {
  function burgerLength(n) {
    let result = [1];

    for (let i = 1; i <= n; i++) {
      let prevLength = result[result.length - 1];
      result.push(prevLength * 2 + 3);
    }

    return result;
  }
  let burgerLengths = burgerLength(50);

  function burgers(n, x) {
    if (x === 0) {
      return 0;
    }

    if (n === 0 && x > 0) {
      return 1;
    }

    // n > 0
    if (x === 1) {
      return 0;
    } else if (x <= burgerLengths[n - 1] + 1) {
      return burgers(n - 1, x - 1);
    } else if (x <= burgerLengths[n] - 1) {
      return (
        (burgerLengths[n - 1] + 1) / 2 +
        1 +
        burgers(n - 1, x - burgerLengths[n - 1] - 2)
      );
    } else {
      return (burgerLengths[n] + 1) / 2;
    }
  }

  const inputs = input.split("\n").filter(x => x !== "");

  let N = Number(inputs[0].split(" ")[0]);
  let X = Number(inputs[0].split(" ")[1]);

  console.log(burgers(N, X));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
