#include <iostream>
using namespace std;
int main()
{
int i,j,k,count;
cin>>i;
while(i--){
cin>>j;
count=0;
while(j){
if(j%2==0) j=j/2;
if(j%2==1){
j=j-1;
count++;
}
}
cout<<count<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int i,j,k,count;
cin>>i;
while(i--){
cin>>j;
count=0;
while(j){
if(j%2==0) j=j/2;
if(j%2==1){
j=j-1;
count++;
}
}
cout<<count<<endl;
}
return 0;
}