n, m = map(int, input().split()) a = [m] for i in range(n - 1): m = (m + 1) // 2 a.append(m) if m == 1: break print(sum(a) + (n - len(a)))