n = int(input()) a = [] while n > 0: a.append(n) n = n//2 print(2*a[0]-sum(a))