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