def f(n): if n==0: return 0 return f(n//2) + ((n-1)//2+1 if n&1==0 else 0) N = int(input()) print(f(N))