""" 奇数なら, +1 して//2 """ import sys from sys import stdin import heapq N,M = map(int,stdin.readline().split()) NN,MM = N,M ans = 0 while MM > 1 and NN > 0: ans += MM NN -= 1 MM = (MM+1)//2 if NN >= 0 and MM == 1: print (ans + NN) sys.exit() print (2**N-1)