#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  bool erased = true;
  string s;
  cin >> s;
  int current_size = s.size();
  int first_size = s.size();
  while (true) {
    vector<int> erase_num;
    if (erased == false || current_size == 0 || s.size() == 1) break;
    erased = false;
    for (i = 0; i <= s.size() - 2; i++) {
      if (s.at(i) != s.at(i + 1)) {
        erased = true;
        s.erase(s.begin() + i, s.begin() + i + 2);
        current_size -= 2;
        i++;
        if (current_size == 0) break;
      }
    }
  }
  cout << first_size - current_size << endl;
  return 0;
}
