N = M = int(input()) s = 0 while N: s += N N //= 2 print(M * 2 - s)