#include <bits/stdc++.h>
using namespace std;
int main() {
  string in;
  string out;
  cin >> in;
  bool flag = true;
  int count = 0;
  while (flag && in.length() > 0) {
    if (in[0] == in[1]) out += in[0];
    for (int i = 1; i < in.length() - 1; i++) {
      if (in[i - 1] == in[i] && in[i] == in[i + 1]) out += in[i];
    }
    if (in[in.length() - 2] == in[in.length() - 1]) out += in[in.length() - 1];
    if (in.length() == out.length())
      flag = false;
    else {
      count++;
      in = out;
      out.clear();
    }
  }
  cout << count;
  return 0;
}
