#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int judge(string a) {
  bool judgement = false;
  for (int i = 0; i < a.length() - 1; ++i) {
    if (a[i] != a[i + 1] && a.length() > 2) {
      judgement = true;
      break;
    }
  }
  return judgement;
}
int main() {
  cin >> s;
  n = s.length();
  while (judge(s) != false) {
    for (int i = 0; i < s.length() - 1; ++i) {
      if (s[i] != s[i + 1]) {
        s.erase(s.begin() + i);
        s.erase(s.begin() + i);
      }
    }
  }
  if (s.length() == 2 && s[0] != s[1]) {
    s.clear();
  }
  if (s.empty()) {
    cout << n << endl;
  } else {
    cout << n - s.length() << endl;
  }
}
