#include <bits/stdc++.h>
using namespace std;
int main() {
  string homu;
  cin >> homu;
  int n = homu.size();
  while (1) {
    string ns = "";
    int idx = 0;
    for (int i = 0; i < (int)homu.size(); ++i) {
      if (i + 1 < homu.size() && homu[i] != homu[i + 1]) {
        ns += homu.substr(idx, i - idx);
        idx = i + 2;
        ++i;
      }
    }
    if (!idx) break;
    ns += homu.substr(idx);
    ns.swap(homu);
  }
  cout << n - homu.size() << endl;
  return 0;
}
