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