def solve(n) return 0 if n < 2 ans = n+1 ans -= 2**n.to_s(2).chars.count('1') ans end while cin = gets p solve(cin.to_i) end