n = int(input()) ans = n * 2 while n >= 1: ans -= n n //= 2 print(ans)