#include<iostream>

using namespace std;

int main(){

         int n,i,s;

         char x;

         cin>>n;

         getchar();

         for(i=0;i<n;i++){

                   s=0;

                   while((x=getchar())!='\n')

                   if(x>='0'&&x<='9')

                   s++;

                   cout<<s<<endl;

         }

         return 0;

}