
var memo;

function lvBerger(n) {
    if (memo[n].length > 0) return memo[n]; //include n=0
    memo[n] = "B" + lvBerger(n - 1) + "p" + lvBerger(n - 1) + "B";
// console.log(n, memo[n]);
    return memo[n];
}

function Main(input) {
    var l0 = input.split(" ");
    var N = l0[0] - 0;
    var X = l0[1] - 0;
    memo = new Array(N + 1).fill("");
    memo[0] = "p";

    var berger = lvBerger(N);

    var count = 0;
    for (var n = 0; n < X; n++) {
        if (berger.charAt(n) == "p") count++;
    }

    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
