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