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