#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.size() == 1) cout << "0" << endl;
  int count = 0;
  if (s.size() != 1) {
    vector<char> vec(s.size());
    for (int i = 0; i < (int)s.size(); i++) vec.at(i) = s.at(i);
    bool A = true;
    while (A) {
      for (int i = 0; i < (int)vec.size() - 1; i++) {
        if (vec.at(i) != vec.at(i + 1)) {
          count += 2;
          vec.erase(vec.begin() + i);
          vec.erase(vec.begin() + i + 1);
        }
        if (vec.size() == 0 || vec.size() == 1) {
          A = false;
          break;
        }
        if (sort(vec.begin(), vec.end()); vec[0] == vec[vec.size() - 1]) {
          A = false;
          break;
        }
      }
    }
    cout << count << endl;
  }
}
