n = int(input()) b = format(n, 'b') ans = n+1-2**b.count('1') print(ans)