#include <bits/stdc++.h>
using namespace std;
bool compress(string& s) {
  if (s == "") {
    return false;
  }
  string tmp = s;
  int sz = tmp.size();
  s = "";
  s += tmp[0];
  for (int i = 1; i < (sz - 1); i++) {
    if (tmp[i] == tmp[i - 1] && tmp[i] == tmp[i + 1]) {
      s += tmp[i];
    }
  }
  if (sz >= 2 && tmp[sz - 1] == tmp[sz - 2]) {
    s += tmp[sz - 1];
  }
  return (s != tmp);
}
int main(int argc, char* argv[]) {
  string s;
  cin >> s;
  int ans = 0;
  while (compress(s)) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}
