#include<iostream>
#include<cctype>
using namespace std;
int n, count;
string str;
int main(){
cin >> n;
while(n--){
cin >> str;
count = 0;
for(int i = 0; i < str.length(); i++)
if(isdigit(str[i])) count++;
cout << count << endl;
}
return 0;
}
//presented by 大吉大利,今晚AC