n, m = map(int, input().split()) if n <= 60 and m >= pow(2, n - 1): print(pow(2, n) - 1) exit() ans = 0 while n > 0 and m != 1: ans += m if m % 2 == 0: m //= 2 else: m += 1 m //= 2 n -= 1 ans += n print(ans)