N = int(input()) t = N tt = 0 while t != 0: tt += t t //= 2 print(N * 2 - tt)