#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string S;
  int prev;
  cin >> S;
  prev = S.size();
  while (S.size()) {
    string::iterator itr;
    bool b = false;
    for (itr = S.begin(); itr < S.end() - 1;) {
      if (*itr != *(itr + 1)) {
        itr = S.erase(itr);
        itr = S.erase(itr);
        b = true;
      } else
        ++itr;
    }
    if (!b) break;
  }
  cout << prev - S.size() << endl;
}
