var input = ''
process.stdin.on('data', (chunk)=>{
input += chunk
});
process.stdin.on('end', ()=>{
input = input.split('\n')
//console.log(input)
let testcases= Number(input[0]);
let i=1;
while(testcases--){
let X=Number(input[i]);
sol(X);
i++;
}
});
function isTwo(num){
if(num&&(!(num&(num-1))))return 1
return 0;
}
function sol(inki){
let count=0;
function main(X){
if(!isTwo(X)){
count++;
let numInBin =X.toString(2);
let MSB = numInBin.length-1;
let Y=2**MSB;
let remaining = X-Y;
//console.log("numInBin ",numInBin," MSB ",MSB," Y ",Y," remaining ",remaining);
if(!isTwo(remaining)){
main(remaining);
}
}
}
main(inki)
console.log(count);
}