#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<char> s;
  char name;
  int count = 0, k = 0;
  while (cin >> name) {
    s.push_back(name);
  }
  while (1) {
    for (int i = 0; i < s.size() - 1; ++i) {
      if (s[i] != s[i + 1]) {
        s.erase(s.begin() + i);
        s.erase(s.begin() + (i + 1));
        count += 2;
      }
    }
    int t[10000];
    t[k] = s.size();
    k++;
    if (k > 2 && t[k] == t[k + 1]) break;
  }
  cout << count << endl;
  return 0;
}
