n = int(input()) ans1 = n + n ans2 = 0 while(n > 0): ans2 += n n = n // 2 ans = abs(ans1 - ans2) print(ans)