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;
}

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

    S[51] memo;
    memo[0] = S(1, 1);
    foreach(i; 1..51) {
        memo[i] = S(memo[i-1].all*2+3, memo[i-1].patti*2+1);
    }
    long x = X;
    long count;
    foreach_reverse(i; 1..N+1)
    {
        x--;
        if(x<memo[i].all) continue;

        x -= memo[i].all-1;
        count += memo[i].patti;

        if(x<=0)break;
        x--;
        count++;

        x--;
    }

    if(x==1) count+=1;
    if(x==2) count+=2;
    if(x==3) count+=3;
    writeln(count);
}
