"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};
function buildArray(r,t){let l=t||0;for(let t=r.length;t>0;t--){const n=r[t-1];l=Array(n).fill().map(()=>JSON.parse(JSON.stringify(l)))}return l}

function main(input) {
  var o = new I(input);

  var n = o.a();
  var x = o.a();

  var burgerLength = [];
  burgerLength[1] = 5;
  for (var i = 2; i <= 50; i ++) {
    burgerLength[i] = burgerLength[i - 1] * 2 + 3;
  }
  console.log(burger(n, x));

  function burger(n, x) {
    var y = x;
    if (y > burgerLength[n]) {
      return (burgerLength[n] + 1)/2;
    }

    if (n === 1) {
      return {
        0: 0,
        1: 0,
        2: 1,
        3: 2,
        4: 3,
        5: 3
      }[y];
    }
  
    var b = 0;
    if (y > 1) {
      b += burger(n - 1, y - 1);
    }
    
    if (y > burgerLength[n - 1] + 1) {
      b += 1;
    }

    if (y > burgerLength[n - 1] + 2) {
      b += burger(n - 1, y - burgerLength[n - 1] - 2);
    }

    return b;
  }
}




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