#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  while (1) {
    string memo = "";
    swap(s, memo);
    int i = 0;
    while (i < memo.size()) {
      if (i == memo.size() - 1) {
        s += memo[i];
        break;
      }
      if (memo[i] != memo[i + 1]) {
        i++;
      } else
        s += memo[i];
      i++;
    }
    if (memo == s) break;
  }
  int ans = n - s.size();
  cout << ans << endl;
  return 0;
}
