N = int(input()) b = bin(N).count('1') ans = N+1-2**b print(ans)