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