#include <bits/stdc++.h>
using namespace std;
string remove_block(string s) {
  bool flag = false;
  int i;
  for (i = 1; i < s.length(); i++) {
    if (s[i] != s[i - 1]) {
      flag = true;
      break;
    }
  }
  if (flag) {
    s.erase(i - 1, 2);
    return remove_block(s);
  } else {
    return s;
  }
}
int main() {
  string s;
  cin >> s;
  cout << s.length() - remove_block(s).length();
  return 0;
}
