"use strict";
var a = [1]; //層の総数
var p = [1]; //パテの数
function f(n, x) {
    if (n == 0) {
        return  (x <= 0) ? 0 : 1;
    } else if (x <= 1 + a[n - 1]) {
        return f(n - 1, x - 1);
    } else {
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
    }
}
function Main(input) {
    var l0 = input.split(" ");
    var N = l0[0] - 0;
    var X = l0[1] - 0;

    for (let n = 1; n <= N; n++) {
        a.push(a[n - 1] * 2 + 3);
        p.push(p[n - 1] * 2 + 1);
    }

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