N = int(input()) ans = N * 2 while N: ans -= N N //= 2 print(ans)