H, A = map(int, input().split()) n = 0 ans = 0 while H != 0: ans += pow(2, n) H //= 2 n += 1 print(ans)