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