n = int(input()) cnt_n, cnt_m = 0, 0 m = n while n % 2 == 0: cnt_n += n n //= 2 cnt_n += n * 2 while m: cnt_m += m m //= 2 print(cnt_n - cnt_m)