n=b=int(input());a=n while n:n>>=1;a+=n print(abs(a-b*2))