https://www.acmicpc.net/problem/1074
def init():
n, r, c = map(int, input().split())
return n, r, c, -1
def find_num(start, end, total, first_value):
global ans
sy, sx = start
ey, ex = end
if sy+1 == ey and sx+1 == ex:
if sy==r and sx==c:
ans = first_value
elif sy==r and sx+1==c:
ans = first_value+1
elif sy+1==r and sx==c:
ans = first_value+2
else:
ans = first_value+3
return
if sy <= r <= (sy+ey)//2:
if sx <= c <= (sx+ex)//2:
find_num((sy, sx), ((sy+ey)//2, (sx+ex)//2), total//4, first_value+total//4*0)
else:
find_num((sy, (sx+ex)//2+1), ((sy+ey)//2, ex), total//4, first_value+total//4*1)
else:
if sx <= c <= (sx+ex)//2:
find_num(((sy+ey)//2+1, sx), (ey, (sx+ex)//2), total//4, first_value+total//4*2)
else:
find_num(((sy+ey)//2+1, (sx+ex)//2+1), (ey, ex), total//4, first_value+total//4*3)
n, r, c, ans = init()
find_num((0, 0), (2**n-1, 2**n-1), (2**n)**2, 0)
print(ans)