#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int t;
  cin >> t;

  string word;
  while (t--) {
    cin >> word;
    int count_pal = 0;

    // busco palindroms de llargada 2
    for (int i = 0; i < word.length(); i++) {
      if (i+1 < word.length() and word[i] == word[i+1] and word[i] != '.'){
        count_pal ++;
        word[i+1] = '.';
      }
      if (i+2 < word.length() and word[i] == word[i+2] and word[i] != '.'){
        count_pal ++;
        word[i+2] = '.';
      }
    }

    cout << count_pal << endl;
  }
}