#include <bits/stdc++.h>
using namespace std;
int i, sh, cr, L, add, ans;
string s;
int main() {
  for (cin >> s;;) {
    string t;
    vector<int> sz;
    for (i = cr = 1, sh = L = s.length(); i <= L; i++, cr++)
      if (i == L || s[i] != s[i - 1]) {
        bool end = (i == cr || i == L);
        if (cr > 2 || end) t += s[i - 1], sz.push_back(cr);
        sh = min(sh, end ? cr : max(cr / 2, 1));
        cr = 0;
      }
    if ((L = t.length()) < 2) break;
    s.clear();
    for (i = 0; i < L; i++)
      if ((add = sz[i] - ((i == 0 || i == L - 1) ? sh : sh * 2)) > 0)
        s += string(add, t[i]);
    ans += sh;
  }
  cout << ans << endl;
}
