n = int(input()) i,s = n,0 while i>0: s += i i = i//2 print(n*2-s)