#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int iter = 0;
  int i;
  bool stoptime = false;
  bool isval[1000001];
  char last;
  int lasti;
  for (i = 0; i < n; i++) {
    isval[i] = true;
  }
  while (!stoptime) {
    stoptime = true;
    for (i = 0; i < s.length() && !isval[i]; i++) {
    }
    last = s[i];
    lasti = i;
    for (i = 0; i < s.length(); i++) {
      if (isval[i] && (s[i] != last)) {
        isval[lasti] = false;
        isval[i] = false;
        last = s[i];
        lasti = i;
        stoptime = false;
      }
    }
    if (!stoptime) iter++;
  }
  cout << iter << endl;
}
