N, M = map(int, input().split()) cnt = N - 1 ans = 0 while M > 1 and cnt > 0: cnt -= 1 ans += M M = (M + 1) // 2 print(ans + cnt + 1)