"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

let a = [1],
  p = [1];

reader.on("line", line => {
  let input = line.split(/\s/);
  let n = parseInt(input[0]);
  let x = parseInt(input[1]);

  for (let i = 1; i <= n; i++) {
    a.push(2 * a[i - 1] + 3);
    p.push(2 * p[i - 1] + 1);
  }
  
  console.log(f(n, x));
});

function f(n, x) {
  if (n == 0) {
    if (x <= 0) return 0;
    else return 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]);
  }
}
