#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2 = "";
  getline(cin, s1);
  int count = 0;
  int flag = 0;
  int k = 0;
  int n = s1.length();
  int i = 0;
  while (1) {
    count++;
    for (i = 0; i < n - 1; i++) {
      if (s1[i] == s1[i + 1])
        s2 += s1[i];
      else
        i++;
    }
    if (i == n - 1) s2 += s1[i];
    s1 = s2;
    s2 = "";
    n = s1.length();
    flag = 0;
    for (i = 0; i < n - 1; i++)
      if (s1[i] != s1[i + 1]) flag = 1;
    if (flag == 0) break;
  }
  cout << count;
}
