def check_count(n): p_count = 0 ans = 0 if n == 1: return 1 while 2**p_count <= n: p_count += 1 if 2**(p_count - 1) == n: return (p_count - 1) else: ans = p_count - 1 ans += check_count(n - 2**(p_count-1)) return ans n = int(input()) if n == 1: print(0) else: print(check_count(n))