#include <bits/stdc++.h>
using namespace std;
string s;
queue<pair<int, int> > Q;
int ans = 0, f[1500000], nx[1500000], pr[1500000];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] != s[i + 1]) Q.push(make_pair(i, 0));
    f[i] = 0;
    nx[i] = i + 1;
  }
  for (int i = 0; i < s.length(); i++) {
    pr[i] = i - 1;
  }
  while (!Q.empty()) {
    int x = Q.front().first, y = Q.front().second;
    Q.pop();
    if (s[x] == s[nx[x]] || f[x] == 1 || f[nx[x]] == 1) continue;
    ans = max(ans, y + 1);
    f[x] = 1;
    f[x + 1] = 1;
    nx[pr[x]] = nx[nx[x]];
    pr[nx[nx[x]]] = pr[x];
    if (pr[x] != -1) Q.push(make_pair(pr[x], y + 1));
  }
  cout << ans;
}
