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