#include <bits/stdc++.h>
using namespace std;
vector<pair<char, int>> group;
vector<pair<char, int>> tempor;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt = 0;
  int left = 0, right = 0;
  while (left < s.size()) {
    while (right + 1 < s.size() && s[left] == s[right + 1]) right++;
    group.push_back({s[left], right - left + 1});
    left = right + 1;
    right = left;
  }
  int ans = 0;
  int temp = 0;
  while (group.size() > 1) {
    for (int x = 0; x < group.size(); x++) {
      if (x == 0 || x == group.size() - 1) {
        temp = group[x].second - 1;
      } else
        temp = group[x].second - 2;
      if (temp > 0) {
        tempor.push_back({group[x].first, temp});
      }
    }
    ans++;
    group = tempor;
    tempor.clear();
  }
  cout << ans << endl;
  return 0;
}
