using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using CHY72;

namespace CHY72{
    
    public class PointXY{
        public int X , Y;
        public int SQLength() { return X * X + Y * Y; }
        public bool Flag = false;
        public PointXY(int _X,int _Y) {
            X = _X; Y = _Y;
        }
        public PointXY(PointXY P1, int _X = 0, int _Y = 0) {
            X = P1.X +  _X; Y =P1.Y + _Y;
        }
        public static bool operator ==(PointXY P1, PointXY P2) {
            return (P1.X== P2.X && P1.Y == P2.Y);
        }
        public static bool operator !=(PointXY P1, PointXY P2) {return !(P1 ==P2);}
        public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}
        public override bool Equals(object obj) {
            if (obj == null || this.GetType() != obj.GetType()) {return false;}
            return (this == (PointXY)obj);
        }

    }

    public class Lib72 {
        public static int NumFromChar(char CNUM) { return CNUM - 48; }

        public static int[] KETAArray(int Num) {return KETAArray(Num.ToString()); }
        public static int[] KETAArray(string Num) {
            char[] cKETA = Num.ToCharArray();
            int[] iKETA = new int[cKETA.Length];
            for (int i = 0; i < iKETA.Length; i++) {
                iKETA[i] = NumFromChar(cKETA[i]);
            }
            return iKETA;
        }
        public static int KETA(int Num) { return Num.ToString().ToCharArray().Length; }
        public static int FromKETAArray(int[] _ketaarray) {
            int result = 0;
            int[] R_ketaarray = _ketaarray.Reverse().ToArray(); 
            for (int i = 0,j=1; i < R_ketaarray.Length; i++,j *=10) {
                result += j * R_ketaarray[i];
            }
            return result;
        }
        public static bool isPrime(int p) {
            if (p != 2 && p % 2 == 0) return false;
            if (p == 1) return false;
            int SQp = (int)(Math.Sqrt(p));
            for (int i = 3; i <= SQp; i++) {
                if (p % i == 0) return false;
            }
            return true;
        } 
    }
}    

public class Program {
    static bool ReadLine_1(ref int num1, bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str);
        return (Fin0 && num1 == 0);
    }
    static int  ReadLine_1() {
        return  int.Parse(Console.ReadLine());
    }
    static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true,int FinNum =0) {
        string str = Console.ReadLine();
        num1 = int.Parse(str.Split(Spliter)[0]);
        num2 = int.Parse(str.Split(Spliter)[1]);
        return (Fin0 && num1 == FinNum && num2 == FinNum);
    }
    static int[] ReadLine72(char Spliter = ' ') {
        return Console.ReadLine().Split(Spliter).Select(s => int.Parse(s)).ToArray();
    }

    const int DefaultMax = 72727272;



    static void Main(string[] args) {
        int Q = ReadLine_1();
        for (int i = 0; i < Q; i++) {
            int N = ReadLine_1(); int R = 0;
            while (true){
                if (Lib72.KETA(N) == 1) break;
                string Nstr = "" + N;
                break;

                R++;
            }
            Console.WriteLine(R + " ");
        }
    }
}