import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
import std.typecons; 

struct S{
    long all;
    long patti;
}

S[51] memo;
void main()
{
    const input = readln().strip.split.to!(long[]);
    const N = input[0];
    const X = input[1];
    memo[0] = S(1, 1);

    foreach(i; 1..51) {
        memo[i] = S(memo[i-1].all*2+3, memo[i-1].patti*2+1);
    }

    writeln(func(N, X));
}

long func(long n, long x)
{
    if(n==0)
        return x<=0?0:1;
    else if(x <= 1+memo[n-1].all)
        return func(n-1, x-1);
    else
        return memo[n-1].patti+1+func(n-1, x-2-memo[n-1].all);
}