// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    auto word = scan!(dchar[]);
    int n = word.length.to!int;
    auto vis = new bool[n];
    int cnt = 0;
    for(int i = 0; i < n-1; ++i){
        if(vis[i]) continue;

        if(i < n - 2 && word[i] == word[i+1] && word[i] == word[i+2]){
            cnt += 2; vis[i+1] = 1; vis[i+2] = 1;
        }else if(word[i] == word[i+1]){
            ++cnt; vis[i+1] = 1;
        }else if(i < n - 2 && word[i] == word[i+2]){
            ++cnt; vis[i+2] = 1;
        }
    }
    writeln(cnt);
}

void main(){
    long tests = 1;
    tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] tk;
T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");
