//#include "bits/stdc++.h"
#include <string>
#include <iostream>
#include <bitset>
#include <cassert>
#include <algorithm>
using namespace std;

int solve(long n)
{
	bitset<30> bs(n);
	string s = bs.to_string();
	int cnt = 0;
	while (s != "")
	{
	    int L = 0;
	    while (s[L] != '1' && L < s.length())
			++L;
		if (L == s.length()) break;
		
        s = s.substr(L, s.length() - L);
        
		// cout << "before " <<  s << endl;
		
		reverse(s.begin(), s.end());
		
		s = s.substr(0, s.length() - 1);

        // cout << "after  " <<  s << endl;

		++cnt;
	}

	return cnt;
}

int main()
{
	long a;
	
	while (cin >> a)
	    cout << solve(a);

	return 0;
}
