#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  string S;
  cin >> S;
  int count = 0;
  int len = S.length();
  if (len == 1) {
    cout << count << endl;
    return 0;
  }
  if (len == 2) {
    if (S[0] == S[1])
      cout << count << endl;
    else
      cout << count + 2 << endl;
    return 0;
  }
  for (int i = 1; i < len;) {
    if (S.length() <= 2 && S[0] == S[1]) break;
    if (S[i] == S[i - 1]) {
      i++;
    } else {
      S.erase(S.begin() + i);
      S.erase(S.begin() + i - 1);
      len = len - 2;
      count = count + 2;
      i--;
      if (len <= 0) break;
    }
  }
  cout << count << endl;
}
