n, m = map(int, input().split()) i = 1 for _ in range(n - 1): i *= 2 if i > m: break else: print(2 * i - 1) exit() ans = 0 for i in range(1, n + 1): ans += m if m % 2 == 1: m += 1 m //= 2 if m == 1: ans += n - i break print(ans)