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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main extends PrintWriter {
    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
    Main () { super(System.out); }
    public static void main(String[] args) throws IOException{
        Main  d1=new Main   ();d1.main();d1.flush();
    }
    void main() throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb = new StringBuffer();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        t = i(s()[0]);
        while (t-- > 0) {
          char[] a=s()[0].toCharArray();
          int ans=0;
          for(int i=0;i<a.length-1;i++){
              if(a[i]=='%') continue;
               if(a[i]==a[i+1]){
                   ans++;
                   if(i+2<a.length&&a[i]==a[i+2]){
                       ans++;i+=2;
                   }else i+=1;
               }else if(i+2<a.length&&a[i]==a[i+2]){
                   ans++;a[i+2]='%';
               }
           }
           sb.append(ans+"\n");
        }
        System.out.println(sb);

        }static StringBuffer ans;static int[][] vis;static int[][] px,py;
    public static void dfs(char[][] a,int i,int j) {
        Queue<Integer> qx = new LinkedList<>();
        Queue<Integer> qy = new LinkedList<>();
        Queue<StringBuffer> qz = new LinkedList<>();
        qx.add(i);
        qy.add(j);
        qz.add(new StringBuffer(""));

        while (!qx.isEmpty()) {
            int x = qx.poll();
            int y = qy.poll();

            vis[x][y] = 1;
          //  StringBuffer sb = qz.poll();
            if (a[x][y] == 'A') {
                while(px[x][y]!=-1) {
                    int nx = px[x][y];
                    int ny = py[x][y];
//                    System.out.println(nx + " " + ny + " " + px[nx][ny] + " " + a[x][y]);
                    if (nx < x) {
                        ans.append("U");
                    }
                    if (nx > x) {
                        ans.append("D");
                    }
                    if (ny > y) {
                        ans.append("R");
                    }
                    if (ny < y)
                        ans.append("L");
                    x = nx;
                    y = ny;
                }return ;
            }
//            System.out.println();
            if (x - 1 >= 0 && a[x - 1][y] != '#' && vis[x - 1][y] == 0) {
                px[x-1][y]=x;py[x-1][y]=y;
                vis[x-1][y]=1;
                qx.add(x - 1);
                qy.add(y);

            }
            if (x + 1<a.length && a[x + 1][y] != '#' && vis[x + 1][y] == 0) {
             qx.add(x + 1);vis[x+1][y]=1;
                px[x+1][y]=x;py[x+1][y]=y;
                qy.add(y);

            }
            if (y + 1 < a[0].length && a[x][y + 1] != '#' && vis[x][y + 1] == 0) {
                qx.add(x);vis[x][y+1]=1;
                px[x][y+1]=x;py[x][y+1]=y;
                qy.add(y + 1);
            }
            if (y - 1 >= 0 && a[x][y - 1] != '#' && vis[x][y - 1] == 0) {
                qx.add(x);vis[x][y-1]=1;
                px[x][y-1]=x;py[x][y-1]=y;
                qy.add(y - 1);
            }

        }
    }
    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    static int[][] d={{-1,0},{1,0},{0,-1},{0,1}};
    static boolean wb(int i,int j,int n,int m){
        if(i>=0&&i<n&&j>=0&&j<m) return true;
        return false;
    }
    static String[] s() throws IOException {
        return s.readLine().trim().split("\\s+");
    }
    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
    public void arr(long[] a,int n) throws IOException {
        //        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] s2=s();
        for(int i=0;i<n;i++){
            a[i]=l(s2[i]);
        }
    }
    public void arri(int[] a,int n) throws IOException{
        //        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] s2=s();
        for(int i=0;i<n;i++){
            a[i]=i(s2[i]);
        }
    }
    public void sort(long[] a,int l,int h){
        if(l==h) return;
        int mid=(l+h)/2;

        sort(a,l,mid);
        sort(a,mid+1,h);
        merge(a,l,(l+h)/2,h);
    }
    void merge(long arr[], int l, int m, int r) {
        int n1 = m - l + 1;
        int n2 = r - m;
        long L[] = new long[n1];
        long R[] = new long[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
}
class Pair {
    int  a,b,c;
    public Pair(int  a,int b){
        this.a=a;this.b=b;this.c=c;}
}class Sortbyroll implements Comparator<Pair> {
    public int compare(Pair a, Pair b){
        return a.a-b.a;
    }}
class Sortbyroll1 implements Comparator<Pair> {
    public int compare(Pair a, Pair b){
        return a.b-b.b;
    }}