#include <bits/stdc++.h>
using namespace std;
set<int> seti, set1, set2;
int main() {
  std::ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int i, j;
  set<int>::iterator it1, it2, it;
  int n = s.length();
  for (i = 0; i < n; i++) {
    seti.insert(i);
  }
  for (i = 0; i < n; i++) {
    if (i != n - 1 && s[i] != s[i + 1]) {
      set1.insert(i);
      seti.erase(i);
    } else if (i != 0 && s[i] != s[i - 1]) {
      set1.insert(i);
      seti.erase(i);
    }
  }
  int counter = 0;
  while (!set1.empty()) {
    counter++;
    for (it = set1.begin(); it != set1.end(); it++) {
      it1 = seti.upper_bound(*it);
      if (it1 != seti.begin() && it1 != seti.end()) {
        it2 = it1;
        it2--;
        if (s[*it1] != s[*it2]) {
          set2.insert(*it1);
          set2.insert(*it2);
        }
      }
    }
    set1.clear();
    for (it = set2.begin(); it != set2.end(); it++) {
      set1.insert(*it);
      seti.erase(*it);
    }
    set2.clear();
  }
  cout << counter << endl;
  return 0;
}
