#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1 << 29);
int main() {
  string S;
  cin >> S;
  int N = S.size();
  bool flag = false;
  while (true) {
    if (S.empty()) {
      break;
    }
    bool flag2 = false;
    for (int i = 0; i < S.size() - 1; i++) {
      if (S[i] != S[i + 1]) {
        S.erase(i, 2);
        break;
      }
      if (i == S.size() - 2) {
        flag = true;
      }
    }
    if (flag || N == S.size()) {
      break;
    }
  }
  cout << N - S.size() << endl;
  return 0;
}
