N = int(input()) N_orig = N normal = 0 while N: normal += N N //= 2 skill = N_orig*2 ans = skill - normal print(ans)