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