#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T;
  cin >> S;
  int j, count, k, start;
  count = 0;
  start = -1;
  for (int i = 0; i < S.size(); i++) {
    T.at(i) = S.at(i);
  }
  k = 0;
  while (start != count) {
    start = count;
    for (int i = 0; i < T.size();) {
      if ((T.at(i) == T.at(i + 1)) && (T.at(i) != 2)) {
        count = count + 1;
        k = i + 2;
        for (; k < T.size(); k++) {
          T.at(k - 2) = T.at(k);
          T.at(T.size() - 1) = 2;
          T.at(T.size()) = 2;
        }
        i = i + 2;
      } else {
        i++;
      }
    }
  }
  cout << count << endl;
}
