Problem: After his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but passing through them proved to be even more challenging. Mostly because of Cerberus, the three-headed hound of Hades. 

Orpheus, a famous poet, and musician plans to calm Cerberus with his poetry and safely walk past him. He created a very peculiar poem for Cerberus. It consists only of lowercase English letters. 

We call a poem's substring a palindrome if and only if it reads the same backwards and forwards. A string a is a substring of a string b if a can be obtained from b by deleting several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end.

Unfortunately, Cerberus dislikes palindromes of length greater than 1. For example in the poem abaa the hound of Hades wouldn't like substrings aba and aa.

Orpheus can only calm Cerberus if the hound likes his poetry. That's why he wants to change his poem so that it does not contain any palindrome substrings of length greater than 1.

Orpheus can modify the poem by replacing a letter at any position with any lowercase English letter. He can use this operation arbitrarily many times (possibly zero). Since there can be many palindromes in his poem, he may have to make some corrections. But how many, exactly? Given the poem, determine the minimal number of letters that have to be changed so that the poem does not contain any palindromes of length greater than 1.

Input

The first line of the input contains a single integer t (1 ≤ t ≤ 10^5) denoting the number of test cases, then t test cases follow.

The first and only line of each test case contains a non-empty string of lowercase English letters, Orpheus' poem.

The sum of the length of Orpheus' poems in all test cases will not exceed 10^5.

Output

You should output t lines, i-th line should contain a single integer, answer to the i-th test case.

Example

Input


7
babba
abaac
codeforces
zeroorez
abcdcba
bbbbbbb
a


Output


1
1
0
1
1
4
0

Note

In the first test case, we can replace the third character with c and obtain a palindrome-less poem bacba.

In the second test case, we can replace the third character with d and obtain a palindrome-less poem abdac.

In the third test case, the initial poem already doesn't contain any palindromes, so Orpheus doesn't need to change anything there.

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;  
import java.util.Map.Entry;
 
public class Solution{
    // public static class pair{
    //     int x;
    //     int y;
    // }
    public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
        public String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}public double nextDouble() {
			return Double.parseDouble(next());
		}
    }
    public static class Pair implements Comparable<Pair>{
        private int x;
        private int y;
        private int c;
        public Pair(int a,int b,int cost){
            x=a;
            y=b;
            c=cost;
        }
        public Pair clone() {
			return new Pair(x, y,c);
		}
        @Override
		public int compareTo(Pair o) {
			if (x > o.x) {
				return 1;
			}
			if (x < o.x) {
				return -1;
			}
			if (y > o.y) {
				return 1;
			}
			if (y < o.y) {
				return -1;
			}
			if (c > o.c) {
				return 1;
			}
			if (c < o.c) {
				return -1;
			}
			return 0;
		}
    }
    static long[] fac=fact();
    static long[] fact(){
        long[] fac = new long[200001];
        fac[0] = (long)1;
        for (int i = 1; i < (int)fac.length; i++){
            fac[i] = (fac[i - 1] * i) % 1000000007;
        }
        return fac;
    }
    public static int[] p;
    public static int find(int u){
        while(p[u]!=u){
            u=p[u];
        }
        return u;
    }
    public static void union(int u,int v){
        int x=find(u);
        int y=find(v);
        p[x]=y;
    }
    static class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } }

    public static void main(String[] args) throws IOException{
        FastScanner fs=new FastScanner();
		int t=fs.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		while(t-->0){
		    String s=fs.next();
		    int n=s.length();
		    HashSet<Integer> set=new HashSet<>();
		    for(int i=0;i<n-1;i++){
		        if(s.charAt(i)==s.charAt(i+1)){
		            if(!set.contains(i)){
		                set.add(i+1);
		            }
		        }
		        if(i-1>=0 && s.charAt(i-1)==s.charAt(i+1)){
		            if(!set.contains(i-1) && !set.contains(i+1)){
		                set.add(i+1);
		            }
		        }
		    }
		    System.out.println(set.size());
		}
        out.close();
    }
    
    public static float area(Point A, Point B, Point C) { float area = (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)) / 2.0f; return Math.abs(area); }

    public static boolean getans(int v,int[] arr,int b,int a){
        int low=Math.min(a,b);
        int high=Math.max(a,b)-2;
        int t=low;
        int ans=0;
        int i=0;
        while(i<arr.length){
            // System.out.println(arr[i]+" "+t);
            if(arr[i]<=t){
                t++;
                ans++;
                i++;
            }else{
                t=arr[i];
            }
            if(t>high){
                break;
            }
        }
        // if(v==2){
        //     System.out.println(ans+" "+low+" "+high);
        // }
        if(v==3){
            // System.out.println(ans);
        }
        if(ans>=v){
            return true;
        }
        return false;
    }
    public static String call(int in,char[] arr){
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<in;i++){
            sb.append(arr[i]+"");
        }
        sb.append(arr[arr.length-1]+"");
        for(int i=in+1;i<arr.length-1;i++){
            sb.append(arr[i]+"");
        }
        sb.append(arr[in]+"");
        return sb.toString();
    }
    // public static long gcdFind(long[] arr){
    //     long result = (long)0; 
    //     for (long element: arr){ 
    //         result = gcd(result, element);
  
    //         if(result == (long)1) 
    //         { 
    //           return 1; 
    //         } 
    //     } 
    //     return result;
    // }
    public static int dfs(int in,ArrayList<Integer>[] adj,HashSet<Integer> set,HashMap<Integer,Integer> vis){
        if(vis.containsKey(in)){
            return 1;
        }
        if(set.contains(in)){
            return 0;
        }
        vis.put(in,1);
        ArrayList<Integer> l=adj[in-1];
        if(l.size()==0){
            return 2;
        }
        return dfs(l.get(0),adj,set,vis);
    }
    public static boolean check(long n){
        String s=n+"";
        HashMap<Integer,Integer> set=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!='0'){
                set.put(s.charAt(i)-'0',1);
            }
        }
        for(int key:set.keySet()){
            if(n%key!=0){
                return false;
            }
        }
        return true;
    }
    public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<>();
		for(int i:array){
			copy.add(i);
		}
		Collections.sort(copy);
		for(int i=0;i<array.length;i++){
			array[i]=copy.get(i);
		}
	}
    static long power(long x, long y, long p){
        long res = 1;
        x = x % p;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x) % p;
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }
    public static long modInverse(long n, long p){
        return power(n, p - 2, p);
    }
    public static long nCr(long n, long r,long p){
        if (n<r) 
              return (long)0;
        if (r == 0)
            return (long)1;
        return (fac[(int)n] * modInverse(fac[(int)r], p)% p * modInverse(fac[(int)(n - r)], p)% p)% p;
    }
    public static int upp(int[] arr,int v){
        int low=0;
        int high=arr.length-1;
        int ans=-1;
        while(low<=high){
            int m=(low+high)/2;
            if(arr[m]<v){
                ans=m;
                low=m+1;
            }else{
                high=m-1;
            }
        }
        return ans+1;
    }
    public static int low(int[] arr,int v){
        int low=0;
        int high=arr.length-1;
        int ans=-1;
        while(low<=high){
            int m=(low+high)/2;
            if(arr[m]>v){
                ans=m;
                high=m-1;
            }else{
                low=m+1;
            }
        }
        return ans;
    }
    public static class Comp implements Comparator<Pair>{
        public int compare(Pair a,Pair b){
            return a.c-b.c;
        }
    }
    public static int gcd(int a,int b){
        if (b == 0) 
        return a; 
        return gcd(b, a % b);
    }
    public static int lcm(int a,int b){
        int x=Math.max(a,b);
        int y=Math.min(a,b);
        long ans=x;
        while(ans%y!=0){
            ans+=x;
        }
        if(ans>Integer.MAX_VALUE){
            return -1;
        }
        return (int)ans;
    }
    public static long fact(int n){
        long ans=1;
        for(int i=1;i<=n;i++){
            ans*=i;
        }
        return ans;
    }
}