#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n, a, cnt;
  cnt = 0;
  n = a = s.size();
  for (int j = 0; j < (n + 1) / 2; j++) {
    for (int i = 0; i < a - 1; i++) {
      if (s.at(i) != s.at(i + 1)) {
        cnt += 2;
        s.erase(i, 2);
        a -= 2;
      }
    }
  }
  cout << cnt << endl;
}
