N = int(input()) skill = N << 1 normal = 0 while N > 0: normal += N N >>= 1 print(skill - normal)