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.
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Map.Entry;

import java.util.Random;
import java.util.TreeSet;

public final class CF_2020_GoodBye_C
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void logWln(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static void logBin(int[] tm) {for (int x:tm) logWln(bin(8,x)+" ");log("");}

	static String bin(int L,int x) {
		String s=Integer.toBinaryString(x);
		while (s.length()<L) s="0"+s;
		return s;
	}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x; 
	}


	static class Composite implements Comparable<Composite>{

		int val;
		int idx;
		int time;


		public int compareTo(Composite X) {
			if (val!=X.val)
				return -val+X.val;
			if (time!=X.time) 
				return time-X.time;

			return idx-X.idx;
		}


		public Composite(int val, int idx,int tm) {
			this.val = val;
			this.idx = idx;
			this.time=tm;
		}

		public String toString() {
			return val+" "+idx+" "+time;
		}


	}




	static long mod=1000000007;



	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static int[][] dd={{-1,0},{0,1},{1,0},{0,-1}};

	static int CX=26;


	static void remove(int index,int[] left,int[] right) {
		int u=left[index];
		int v=right[index];
		if (v>=0) {
			left[v]=u;
		}
		if (u>=0) {
			right[u]=v;
		}

	}

	static void add(TreeSet<Integer> ts,char[] c,int pos) {
		if (pos>=0 && pos<c.length)
			ts.add((int)c[pos]-'a');
	}

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);



		int T=reader.readInt();
		int NX=100002;
		int[] mem=new int[NX];
		int time=1;
		for (int t=0;t<T;t++) {
			int cnt=0;
			String s=reader.readString();


			char[] c=s.toCharArray();
			int cur=0;
			int n=s.length();
			while (cur<n) {
				//log("looking at :"+c[cur]);
				if (cur+1<n && c[cur]==c[cur+1]) {
					cnt++;
					// we will replace [cur+1]
					TreeSet<Integer> ts=new TreeSet<Integer>();
					add(ts,c,cur-1);
					add(ts,c,cur);
					add(ts,c,cur+2);
					add(ts,c,cur+3);
					for (int u=0;u<26;u++) {
						if (!ts.contains(u)) {

							//log("replacing :"+c[cur+1]+" by:"+(char)(u+'a'));
							c[cur+1]=(char)(u+'a');
							break;
						}
					}
				}
				if (cur+2<n && c[cur]==c[cur+2]) {
					cnt++;
					// we will replace [cur+2]
					// must be different from cur, cur+1,cur+3,cur+4
					TreeSet<Integer> ts=new TreeSet<Integer>();
					add(ts,c,cur);
					add(ts,c,cur+1);
					add(ts,c,cur+3);
					add(ts,c,cur+4);
					for (int u=0;u<26;u++) {
						if (!ts.contains(u)) {
							//log("replacing :"+c[cur+2]+" by:"+(char)(u+'a'));
							c[cur+2]=(char)(u+'a');
							break;
						}
					}
				}
				cur++;
			}
			output(cnt);
			//log(new String(c));


		}
		try {
			out.close();
		} catch (Exception Ex) {
		}

	}




	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String readString(int L) throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder(L);
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}