#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  long long len = S.size();
  while (true) {
    bool f = false;
    for (long long i = 1; i < (long long)S.size(); ++i) {
      if (S[i - 1] != S[i]) {
        S.erase(i - 1, 2);
        f = true;
        break;
      }
    }
    if (!f) break;
  }
  cout << len - S.size() << endl;
}
