var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	var n = input[0][0];
	var x = input[0][1];
	var ans = 0;
	var ls = [1];
	var ps = [1];
	for(var i = 1; i < 51; i++){
		ls[i] = 2*ls[i-1] + 3;
		ps[i] = 2*ps[i-1] + 1;
	}

	function eatP(n,k){
		if(n < 0) return 0;
		if(k >= ls[n]) return ps[n];
		if(k <= 0) return 0;
		var l = ls[n-1];

		return eatP(n-1,k-1) + eatP(0,k-l-1) + eatP(n-1,k-l-2);

	}

	ans = eatP(n,x);
	
	console.log(ans);
}