def f(n):

    if n==0:

        return 1

    return 2*f(n-1)+3

def g(n):

    if n==0:

        return 1

    return 2*g(n-1)+1

def F(n,x):

    if n==0:return 1

    if x<=n:return 0

    if x<=f(n-1)+1:

        return F(n-1,x-1)

    elif x==f(n-1)+2:

        return g(n-1)+1

    else:

        return g(n-1)+1+F(n-1,x-f(n-1)-2)

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

print((F(N,X)))
memo1 = {}

def cho(n):

    if n==0:

        return 1

    if n in memo1:

        return memo1[n]

    memo1[n] = 2*cho(n-1)+3

    return memo1[n]

memo2 = {}

def pat(n):

    if n==0:

        return 1

    if n in memo2:

        return memo2[n]

    memo2[n] = 2*pat(n-1)+1

    return memo2[n]

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

cnt = 0

k = N

while X>0:

    if X==1:

        if k==0:

            cnt += 1

        break

    elif X<=cho(k)//2:

        k -= 1

        X -= 1

    elif X==cho(k)//2+1:

        cnt += 1+pat(k-1)

        break

    elif X==cho(k):

        cnt += pat(k)

        break

    else:

        cnt += pat(k-1)+1

        X -= cho(k-1)+2

        k -= 1

print(cnt)
def f(n):
    if n == 0:
        return 1
    return 2 * f(n - 1) + 3


def g(n):
    if n == 0:
        return 1
    return 2 * g(n - 1) + 1


def F(n, x):
    if n == 0:
        return 1
    if x <= n:
        return 0
    if x <= f(n - 1) + 1:
        return F(n - 1, x - 1)
    elif x == f(n - 1) + 2:
        return g(n - 1) + 1
    else:
        return g(n - 1) + 1 + F(n - 1, x - f(n - 1) - 2)


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

memo1 = {}


def cho(n):
    if n == 0:
        return 1
    if n in memo1:
        return memo1[n]
    memo1[n] = 2 * cho(n - 1) + 3
    return memo1[n]


memo2 = {}


def pat(n):
    if n == 0:
        return 1
    if n in memo2:
        return memo2[n]
    memo2[n] = 2 * pat(n - 1) + 1
    return memo2[n]


N, X = list(map(int, input().split()))
cnt = 0
k = N
while X > 0:
    if X == 1:
        if k == 0:
            cnt += 1
        break
    elif X <= cho(k) // 2:
        k -= 1
        X -= 1
    elif X == cho(k) // 2 + 1:
        cnt += 1 + pat(k - 1)
        break
    elif X == cho(k):
        cnt += pat(k)
        break
    else:
        cnt += pat(k - 1) + 1
        X -= cho(k - 1) + 2
        k -= 1
print(cnt)

-def f(n): +memo1 = {} + + +def cho(n): -    return 2 * f(n - 1) + 3 +    if n in memo1: +        return memo1[n] +    memo1[n] = 2 * cho(n - 1) + 3 +    return memo1[n] -def g(n): +memo2 = {} + + +def pat(n): -    return 2 * g(n - 1) + 1 - - -def F(n, x): -    if n == 0: -        return 1 -    if x <= n: -        return 0 -    if x <= f(n - 1) + 1: -        return F(n - 1, x - 1) -    elif x == f(n - 1) + 2: -        return g(n - 1) + 1 -    else: -        return g(n - 1) + 1 + F(n - 1, x - f(n - 1) - 2) +    if n in memo2: +        return memo2[n] +    memo2[n] = 2 * pat(n - 1) + 1 +    return memo2[n] -print((F(N, X))) +cnt = 0 +k = N +while X > 0: +    if X == 1: +        if k == 0: +            cnt += 1 +        break +    elif X <= cho(k) // 2: +        k -= 1 +        X -= 1 +    elif X == cho(k) // 2 + 1: +        cnt += 1 + pat(k - 1) +        break +    elif X == cho(k): +        cnt += pat(k) +        break +    else: +        cnt += pat(k - 1) + 1 +        X -= cho(k - 1) + 2 +        k -= 1 +print(cnt)