#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, dop;
  cin >> s;
  int check = 1, count = 0;
  while (check == 1 && s != "") {
    check = 0;
    if (s[0] == s[1])
      dop += s[0];
    else
      check = 1;
    for (int i = 1; i < s.size() - 1; i++) {
      if (s[i] != s[i - 1] || s[i] != s[i + 1])
        check = 1;
      else
        dop += s[i];
    }
    if (s[s.size() - 1] == s[s.size() - 2])
      dop += s[s.size() - 1];
    else
      check = 1;
    if (check == 1) count++;
    s = dop;
    dop = "";
  }
  cout << count;
}
