#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int nowSize = n;
  bool hasErased = false;
  do {
    hasErased = false;
    for (int i = 0; i <= nowSize - 2; i++) {
      if (s[i] != s[i + 1]) {
        s.erase(i, 2);
        hasErased = true;
        nowSize = s.size();
        break;
      }
    }
  } while (hasErased);
  cout << n - nowSize << endl;
  return 0;
}
