N = int(input()) c = bin(N).count('1') print(2**c - 2)