import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
 
void main() {
	auto data = readln.split;
	auto N = data[0].to!long, X = data[1].to!long;
	
	long height(long level) { return 2^^(level+2) - 3; }
	long p_num(long level) { return 2^^(level+1) - 1; }
	
	long solve(long level, long x) {
		if (level == 0 || x == 0) return x;
		auto h = height(level-1);
		if (x <= h+1)        return solve(level-1, x-1);
		else if (x <= 2*h+2) return p_num(level-1) + 1 + solve(level-1, x-h-2);
		else return p_num(level);
	}
	writeln(solve(N, X));
}
