uva11332測資A

Input:
1
21
321
5566
99999
789876
1000000
20000002
120340560
1999999999
0
Output:
1
3
6
4
9
9
1
4
3
1