#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.length(), ans = 0;
  vector<char> s(N);
  for (int i = 0; i < N; i++) s[i] = S[i];
  while (1) {
    N = S.length();
    bool f = true;
    vector<char> tmp;
    int i;
    for (i = 0; i < N - 1; i++) {
      if (s[i] ^ s[i + 1])
        i++, ans++, f = false;
      else
        tmp.push_back(s[i]);
    }
    if (i == N - 1) tmp.push_back(s[i]);
    if (f) break;
    s = tmp;
  }
  cout << ans << endl;
}
