N = int(input()) w = N ans = 0 while True: if w == 0: break ans += w w = w // 2 ans = 2*N - ans print(ans)