#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int s_len = S.length();
  while (true) {
    int found_pos = -1;
    for (auto i = 0; i < S.length() - 1; i++) {
      if (S.at(i) != S.at(i + 1)) {
        found_pos = i;
      }
    }
    if (found_pos == -1) {
      break;
    } else {
      S.erase(found_pos, 2);
      if (S.length() == 0) {
        break;
      }
    }
  }
  cout << s_len - S.length() << endl;
  return 0;
}
