#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
  string second;
  cin >> second;
  int n = second.size();
  for (int i = 0; i < second.size(); i++) {
    if (second[i] != second[i + 1]) {
      second.erase(second.begin() + i, second.begin() + i + 2);
      i -= 2;
    }
  }
  cout << n - second.size();
}
