public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
while (in.hasNext()) {
int n = in.nextInt();
for (int i = 0; i < n; i++) {
int sum = 0;
String str = in.next();
char[] a = str.toCharArray();
for (int j = 0; j < a.length; j++) {
if (a[j] >= ‘0‘ && a[j] <= ‘9‘)
sum++;
}
System.out.println(sum);
}
}
}
}