N = int(input()) normal = 0 skilled = 2*N while N > 0: normal += N N //= 2 print(skilled - normal)