#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<char> a;
  string b;
  int ans = 0;
  cin >> b;
  copy(b.begin(), b.end(), back_inserter(a));
  vector<char>::iterator itr = a.begin();
  bool flag = true;
  if (a.size() == 1) {
    cout << 0 << endl;
    return 1;
  }
  while (true) {
    itr = a.begin();
    flag = true;
    for (itr; itr < a.end(); itr++) {
      if (a.size() == 2 && a[0] == a[1]) {
        cout << ans << endl;
        return 1;
      }
      if (itr - 1 != a.end() || (!flag && itr != a.begin())) {
        if (*itr != *(itr + 1)) {
          ans += 2;
          a.erase(itr, itr + 2);
          flag = false;
          if (a.size() != 2) itr--;
        }
      }
    }
    if (flag) {
      cout << ans << endl;
      return 1;
    }
  }
}
