import sys def input(): return sys.stdin.readline().rstrip() from math import floor def main(): H, A = map(int, input().split()) n = 1 ans = 0 while H: ans += n H //= 2 n *= 2 print(ans) if __name__ == "__main__": main()