#include <bits/stdc++.h>
using namespace std;
int check(string s) {
  bool chigau = false;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] - s[i + 1] != 0) chigau = true;
  }
  return chigau;
}
int main(void) {
  int i;
  string s;
  cin >> s;
  int n = s.size();
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (check(s)) {
    for (i = 0; i < s.size() - 1; i++) {
      if (s[i] - s[i + 1] != 0) {
        int x = s.size();
        s.erase(i, i + 1);
        if (x - s.size() == 1) {
          cout << n << endl;
          return 0;
        }
        i = 0;
      }
    }
  }
  cout << n - s.size() << endl;
}
