#include <bits/stdc++.h>
using namespace std;
vector<long long> func(vector<long long> &vv) {
  long long temp;
  temp = vv[0];
  bool flag = false;
  int fl = 0;
  for (long long j = 1; j < vv.size(); j++) {
    if (temp != vv[j]) {
      vv.erase(vv.begin() + j - 1);
      vv.erase(vv.begin() + j - 1);
      fl = 1;
    }
    temp = vv[j];
  }
  if (fl == 0) {
    return vv;
  }
  return func(vv);
}
int main() {
  std::string s;
  cin >> s;
  long long size = s.length();
  char cary[size];
  s.copy(cary, size);
  vector<long long> v(size);
  for (long long i = 0; i < size; i++) {
    v[i] = cary[i];
  }
  vector<long long> v2;
  v2 = func(v);
  cout << size - v2.size() << endl;
  return 0;
}
