#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 0, res = 0;
  char now;
  for (int i = 1; i < s.size() - 1; ++i) {
    if (count == 0) {
      now = s[i];
      ++count;
    } else if (now == s[i]) {
      ++count;
    } else {
      ++res;
      --count;
    }
  }
  cout << res * 2 << endl;
}
