#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector<char> twr(n);
  int temp, stop, ans;
  for (int i = 0; i < n; i++) {
    twr[i] = s[i];
  }
  stop, ans = 0;
  while (1) {
    temp = 0;
    if (twr.size() >= 2) {
      for (int i = 0; i < twr.size() - 1; i++) {
        if (stop) {
          if (twr[i] != twr[i + 1]) {
            twr.erase(twr.begin() + i + 1);
            twr.erase(twr.begin() + i);
            ans += 2;
            temp += 1;
            stop = 0;
          }
        } else {
          stop = 1;
        }
      }
    } else {
      break;
    }
    if (temp == 0) break;
  }
  cout << ans << endl;
  return 0;
}
