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