n = int(input()) if n == 1: print(0) exit() def f(n): exp = 0 t = 1 while n >= t * 2: t *= 2 exp += 1 return exp ans = 0 while n != 0: exp = f(n) n -= 2**exp ans += max(exp, 1) print(ans)