from math import log2 def main(): N, M = map(int, input().split()) sum_ = M value = M ctr = 1 while value > 1: match value % 2: case 0: value //= 2 case 1: value = (value // 2) + 1 ctr += 1 sum_ += value if ctr <= N: print(sum_ + (N - ctr)) return print((1 << N) - 1) if __name__ == "__main__": main()