#include <bits/stdc++.h>
using namespace std;
const long long N = 4e5;
long long cn, l, r;
int main() {
  string s, t;
  cin >> s;
  while (1) {
    cn++;
    t.clear();
    for (long long i = (long long)0; i <= (long long)s.size() - 1; i++) {
      l = (i == 0) ? 0 : (s[i - 1] != s[i]);
      r = (i == s.size() - 1) ? 0 : (s[i + 1] != s[i]);
      if (!(l || r)) t.push_back(s[i]);
    }
    s = t;
    if (!t.size() || t.size() == s.size()) {
      cout << cn << " ";
      return 0;
    }
    if (cn == 1000) break;
  }
  cout << cn << '\n';
}
