# coding: utf-8 import bisect N = int(input()) l = [2**i for i in range(27)] a = bisect.bisect_left(l,N) ans = a N -= l[a] for i in range(a,-1,-1): if l[i] < N: N -= l[i] ans += 1 print(ans)