N, X = list(map(int, input().split()))

if X <= N:

    print((0))

    exit(0)

p = [0]*(N+1)

p[0] = 1

for i in range(1, N+1):

    p[i] = p[i-1]*2 + 3





def solve(N, X):

    ret = 0

    if X == p[N]:

        return((p[N]+1) // 2)

    elif X <= N:

        return(0)

    else:

        if X >= (p[N] + 1) // 2:

            ret += ((p[N-1]+1) // 2) + 1

            X = X - (p[N-1] + 1)

        ret += solve(N-1, X-1)

        return(ret)





print((solve(N, X)))

N, X = list(map(int, input().split()))



L = [0]*(N+1)

L[0] = 1



for i in range(N):

    L[i+1] = L[i]*2 + 3

P = [0]*(N+1)

P[0] = 1

for i in range(N):

    P[i+1] = P[i]*2 + 1





def solve(n, x):

    #print(n, x)

    if x == L[n]:

        return(P[n])

    elif x <= n:

        return(0)

    else:

        ret = 0

        if x >= L[n-1] + 1:

            ret += P[n-1]

            x -= L[n-1] + 1

            if x > 0:

                ret += 1 + solve(n-1, x - 1)

        else:

            ret = solve(n-1, x-1)

        return(ret)





print((solve(N, X)))

N, X = list(map(int, input().split()))
if X <= N:
    print((0))
    exit(0)
p = [0] * (N + 1)
p[0] = 1
for i in range(1, N + 1):
    p[i] = p[i - 1] * 2 + 3


def solve(N, X):
    ret = 0
    if X == p[N]:
        return (p[N] + 1) // 2
    elif X <= N:
        return 0
    else:
        if X >= (p[N] + 1) // 2:
            ret += ((p[N - 1] + 1) // 2) + 1
            X = X - (p[N - 1] + 1)
        ret += solve(N - 1, X - 1)
        return ret


print((solve(N, X)))

N, X = list(map(int, input().split()))
L = [0] * (N + 1)
L[0] = 1
for i in range(N):
    L[i + 1] = L[i] * 2 + 3
P = [0] * (N + 1)
P[0] = 1
for i in range(N):
    P[i + 1] = P[i] * 2 + 1


def solve(n, x):
    # print(n, x)
    if x == L[n]:
        return P[n]
    elif x <= n:
        return 0
    else:
        ret = 0
        if x >= L[n - 1] + 1:
            ret += P[n - 1]
            x -= L[n - 1] + 1
            if x > 0:
                ret += 1 + solve(n - 1, x - 1)
        else:
            ret = solve(n - 1, x - 1)
        return ret


print((solve(N, X)))

-if X <= N: -    print((0)) -    exit(0) -p = [0] * (N + 1) -p[0] = 1 -for i in range(1, N + 1): -    p[i] = p[i - 1] * 2 + 3 +L = [0] * (N + 1) +L[0] = 1 +for i in range(N): +    L[i + 1] = L[i] * 2 + 3 +P = [0] * (N + 1) +P[0] = 1 +for i in range(N): +    P[i + 1] = P[i] * 2 + 1 -def solve(N, X): -    ret = 0 -    if X == p[N]: -        return (p[N] + 1) // 2 -    elif X <= N: +def solve(n, x): +    # print(n, x) +    if x == L[n]: +        return P[n] +    elif x <= n: -        if X >= (p[N] + 1) // 2: -            ret += ((p[N - 1] + 1) // 2) + 1 -            X = X - (p[N - 1] + 1) -        ret += solve(N - 1, X - 1) +        ret = 0 +        if x >= L[n - 1] + 1: +            ret += P[n - 1] +            x -= L[n - 1] + 1 +            if x > 0: +                ret += 1 + solve(n - 1, x - 1) +        else: +            ret = solve(n - 1, x - 1)