N = int(input()) total = 0 for i in range(N): if N >> i == 0: break total += N>>i print(N*2 - total)