N = int(input()) a = 0 M = N while N != 0 : a += N N //= 2 print(M*2-a)