#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long mod = 1e9 + 7;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
void Yes(bool x) {
  if (x)
    cout << "Yes\n";
  else
    cout << "No\n";
}
void YES(bool x) {
  if (x)
    cout << "YES\n";
  else
    cout << "NO\n";
}
void yes(bool x) {
  if (x)
    cout << "yes\n";
  else
    cout << "no\n";
}
long long gcd(long long x, long long y) {
  long long r;
  if (x == 0 || y == 0) {
    fprintf(stderr, "引数エラーです。\n");
    return 0;
  }
  while ((r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b, c, d, n, m, ans = 0, ret = 1000000000000000000LL;
  string s, t;
  bool flag = false;
  cin >> s;
  n = s.size();
  while (1) {
    bool x = false;
    for (int i = (1); i < (s.size()); ++i) {
      if (s[i] != s[i - 1]) {
        s.erase(s.begin() + (i - 1), s.begin() + (i + 1));
        x = true;
      }
    }
    if (!x) break;
  }
  cout << n - s.size() << endl;
  return 0;
}
