n = int(input()) m = n a = 0 while m > 0: a += m m = m // 2 print((n*2)-a)