#include using namespace std; typedef long long ll; ll tr_size[61]; void init() { tr_size[1]=1; for(int i=2;i<=60;i++) { tr_size[i]=2*tr_size[i-1]+1; } } ll num; int main() { init(); while(cin>>num) { int cur=60; int ans=0; while(tr_size[cur]>num) cur--; if(num>=(tr_size[cur]+1)/2+tr_size[cur]) ; else cur--; ans=cur; int cun=ans; while(num) { num-=(1+tr_size[cur]); ans++; while(tr_size[cur]>num) cur--; if(num==tr_size[cur]) { if(cur>cun) ans++; break; } if(num>=(tr_size[cur]+1)/2+tr_size[cur]) ; else cur--; } cout<