#include
using namespace std;
int bintodec(int nos){
int base = 1;
int decval =0;
while(nos){
int lastdig = nos%10;
nos=nos/10;
decval+= lastdigbase;
base=2;
}
return decval;
}
int main(){
int N,nos;
cin>>N;
for (int i = 1;i<=N;i++){
cin>>nos;
cout<<bintodec(nos);
}
}