N, M = map(int, input().split()) res = [] now = M while now > 1: res.append(now) now = (now + 1) // 2 res.reverse() if len(res) <= N: print(sum(res) + N - len(res)) else: print(pow(2, N) - 1)