#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s, t;
  cin >> s;
  t = s;
  int check = 0;
  int count = 0;
  while (count <= 100000) {
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] != s[i + 1]) {
        s.erase(i, 2);
        break;
      }
      if (i == s.size() - 2) count = 100000;
    }
    if (s.size() == 0) break;
    count++;
  }
  cout << t.size() - s.size() << endl;
  return 0;
}
