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.awt.event.MouseAdapter;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
import java.text.DecimalFormat;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
    public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    static long MOD = (long) (1e9 + 7);
    //static int MOD;
    static long MOD2 = MOD * MOD;
    static FastReader sc = new FastReader();
    static int pInf = Integer.MAX_VALUE;
    static int nInf = Integer.MIN_VALUE;

    public static void main(String[] args) {
        int test = 1;
        test = sc.nextInt();
        while (test-- > 0) solve();
        out.flush();
        out.close();
    }
    static long inf = (long)(1e16);
    static int n;
    public static void solve() {
       char[] c = sc.next().toCharArray();
       n = c.length;
       int ans  = 0;
       for(int i = 0; i < n; i++){
           if(e(i+2)&&c[i+2]==c[i]){
               for(char f = 'a'; f <= 'z'; f++){
                   if(f==c[i+2]){
                       continue;
                   }
                   int count = 0;
                   if(f!=c[i]){
                       count++;
                   }
                   if(f!=c[i+1]){
                       count++;
                   }
                   if(e(i+3)){
                       if(c[i+3]!=f){
                           count++;
                       }
                   }
                   else{
                       count++;
                   }
                   if(e(i+4)){
                       if(c[i+4]!=f){
                           count++;
                       }
                   }
                   else{
                       count++;
                   }

                   if(count==4){
                       ans++;
                       c[i+2] = f;
                       break;
                   }
               }
           }
           if(e(i+1)&&c[i]==c[i+1]){
               for(char f = 'a'; f <= 'z'; f++){
                   if(f==c[i+1]){
                       continue;
                   }
                   int count = 0;
                   if(e(i-1)){
                       if(c[i-1]!=f){
                           count++;
                       }
                   }
                   else{
                       count++;
                   }
                   if(e(i)){
                       if(c[i]!=f){
                           count++;
                       }
                   }
                   else{
                       count++;
                   }
                   if(e(i+2)){
                       if(c[i+2]!=f){
                           count++;
                       }
                   }
                   else{
                       count++;
                   }
                   if(e(i+3)){
                       if(c[i+3]!=f){
                           count++;
                       }
                   }
                   else{
                       count++;
                   }
                   if(count==4){
                       ans++;
                       c[i+1] = f;
                       break;
                   }
               }
           }
       }
       //out.println(c);
       for(int i =  0; i < n-1; i++){
           if(c[i]==c[i+1]){
               ans++;
               i++;
           }
       }
       out.println(ans);

    }
    static boolean e(int x){
        return x<n&&x>=0;
    }
    public static String lcs(String s1, String s2){
        int n  = s1.length();
        int m  = s2.length();
        int[][] dp = new int[n+1][m+1];
        int[][] parent = new int[n+1][m+1];
        for(int i= 0 ; i < n; i++){
            for(int j =  0; j < m; j++){
                if(s1.charAt(i)==s2.charAt(j)){
                    dp[i+1][j+1] = 1+dp[i][j];
                }
                else{
                    dp[i+1][j+1] = Math.max(dp[i+1][j],dp[i][j+1]);
//                    dp[i][j+1] = Math.max(dp[i][j+1],dp[i][j]);
//                    dp[i+1][j] = Math.max(dp[i+1][j],dp[i][j]);
                }
            }
        }
        for(int i=  0 ; i < n+1; i++){
            out.println(Arrays.toString(dp[i]));
        }
        return "";
    }

    public static long mul(long a, long b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }
    public static long add(long a, long b) {
        return ((a % MOD) + (b % MOD)) % MOD;
    }

    public static long sub(long a, long b) {
        return ((a % MOD) - (b % MOD)) % MOD;
    }//PrimeFactors


    //Pair Class
    static class Pair implements Comparable<Pair> {
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
        @Override
        public int compareTo(Pair o) {
            if ((this.x == o.x)) {
                return -1*(this.y - o.y);
            }
            return -1*(this.x - o.x);
        }
    }
    static class TPair{
        String s;
        int x;
        int y;

        public TPair(String s,int x, int y) {
            this.s = s;
            this.x = x;
            this.y = y;
        }
    }
    //Shuffle Sort
    static final Random random = new Random();
    static void ruffleSort(int[] a) {
        int n = a.length;//shuffle, then sort
        for (int i = 0; i < n; i++) {
            int oi = random.nextInt(n), temp = a[oi];
            a[oi] = a[i];
            a[i] = temp;
        }
        Arrays.sort(a);
    }
    //Brian Kernighans Algorithm
    static long countSetBits(long n) {
        if (n == 0) return 0;
        return 1 + countSetBits(n & (n - 1));
    }
    //Euclidean Algorithm
    static long gcd(long A, long B) {
        if (B == 0) return A;
        return gcd(B, A % B);
    }
    //Modular Exponentiation
    static long fastExpo(long x, long n) {
        if (n == 0) return 1;
        if ((n & 1) == 0) return fastExpo((x * x) % MOD, n / 2) % MOD;
        return ((x % MOD) * fastExpo((x * x) % MOD, (n - 1) / 2)) % MOD;
    }
    //AKS Algorithm
    static boolean isPrime(long n) {
        if (n <= 1) return false;
        if (n <= 3) return true;
        if (n % 2 == 0 || n % 3 == 0) return false;
        for (int i = 5; i <= Math.sqrt(n); i += 6)
            if (n % i == 0 || n % (i + 2) == 0) return false;
        return true;
    }
    public static long modinv(long x) {
        return modpow(x, MOD - 2);
    }
    public static long modpow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        long x = modpow(a, b / 2);
        x = (x * x) % MOD;
        if (b % 2 == 1) {
            return (x * a) % MOD;
        }
        return x;
    }

    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        //it reads the data about the specified point and divide the data about it ,it is quite fast
        //than using direct

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception r) {
                    r.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());//converts string to integer
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception r) {
                r.printStackTrace();
            }
            return str;
        }
    }
}