#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
bool check[N];
int main() {
  string s, t;
  while (cin >> s) {
    int ans = -1;
    bool flag = 1;
    while (flag) {
      memset(check, 0, sizeof(check));
      t = "";
      flag = 0;
      ans++;
      for (int i = 0; i < s.length(); i++) {
        if ((i == 0 && s[0] != s[1]) ||
            (i == s.length() - 1 && s[s.length() - 1] != s[s.length() - 2]) ||
            (i != 0 && i != s.length() - 1 &&
             (s[i] != s[i - 1] || s[i] != s[i + 1]))) {
          check[i] = 1;
          flag = 1;
        }
      }
      for (int i = 0; i < s.length(); i++) {
        if (check[i] == false) {
          t += s[i];
        }
      }
      s = t;
    }
    printf("%d\n", ans);
  }
}
