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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author dauom
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskC solver = new TaskC();
    int testCount = Integer.parseInt(in.next());
    for (int i = 1; i <= testCount; i++) solver.solve(i, in, out);
    out.close();
  }

  static class TaskC {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      char[] a = in.nextCharArray();
      final int n = a.length;
      int[] p = Manacher.longestPalindrome(a);

      int ans = 0;
      boolean[] toChange = new boolean[n];
      for (int i = 0; i < p.length; i++) {
        if (p[i] > 1) {
          int x = i / 2;
          int y = i / 2;
          if (i % 2 == 0) {
            --x;
            ++y;
          } else {
            ++y;
          }

          if (!toChange[x]) {
            toChange[y] = true;
            ++ans;
          }
        }
      }
      out.println(ans);
    }
  }

  static final class Manacher {
    public static int[] longestPalindrome(char[] s, int start, int end) {
      final int len = end - start + 1;
      final int[] p = new int[(len << 1) + 3];
      final char[] t = new char[p.length]; // filled with '\0'

      t[0] =
          1; // to have t[0] != t[t.length -1] (instead of using "$" & "@" likes most
             // implementations)
      for (int i = 0; i < len; ++i) {
        t[(i << 1) + 2] = s[i + start];
      }

      for (int i = 1, C = 0, R = 0; i < t.length - 1; ++i) {
        int j = (C << 1) - i;

        if (R > i) {
          p[i] = Math.min(R - i, p[j]);
        }

        // attempt to expand palindrome centered at i
        while (t[i + (1 + p[i])] == t[i - (1 + p[i])]) {
          ++p[i];
        }

        // if palindrome centered at i expands past right,
        // adjust center based on expanded palindrome.
        if (i + p[i] > R) {
          C = i;
          R = i + p[i];
        }
      }

      return Arrays.copyOfRange(p, 2, p.length - 2);
    }

    public static int[] longestPalindrome(char[] s) {
      return longestPalindrome(s, 0, s.length - 1);
    }
  }

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

    public InputReader() {
      this.stream = System.in;
    }

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

    private int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final String next() {
      int c;
      while (isSpaceChar(c = this.read())) {}

      StringBuilder result = new StringBuilder();
      result.appendCodePoint(c);

      while (!isSpaceChar(c = this.read())) {
        result.appendCodePoint(c);
      }

      return result.toString();
    }

    private static boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }

    public final char[] nextCharArray() {
      return next().toCharArray();
    }
  }
}