#include <bits/stdc++.h>
using namespace std;
int main() {
  list<char> lt;
  int i, j, num = 0, bf;
  char ch;
  while (scanf("%c", &ch), ch != '\n') lt.push_back(ch);
  list<char>::iterator it, beg, del;
  while (1) {
    int ts = 1;
    it = lt.begin()++;
    beg = lt.begin();
    bf = *lt.begin();
    for (; it != lt.end(); it++) {
      if (*it != bf) {
        bf = *(it);
        del = it++;
        lt.erase(del);
        num++;
        while (it != lt.end() && bf != *(it)) {
          bf = *(it);
          del = it++;
          lt.erase(del);
        }
        ts = 0;
        lt.erase(beg);
      }
      bf = *it;
      beg = it;
    }
    if (ts) break;
  }
  printf("%d", num);
  return 0;
}
