#include <bits/stdc++.h>
using namespace std;
int powerof2(int n)
{
int res = 0;
for (int i = n; i >= 1; i–)
{
if ((i & (i - 1)) == 0)
{
res = i;
break;
}
}
return res;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int count = 0;
while (n)
{
n = n - powerof2(n);
count++;
}
cout << count << endl;
}
}