n, m = map(int, input().split()) ans = 0 while m > 1: ans += m m = (m + 1) // 2 n -= 1 print(ans + n)