N = int(input()) print(N+1-(2**bin(N).count("1")))