#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  while (S.size() > 1) {
    int temp = 0;
    for (int i = 0; i < S.size() - 1; i++) {
      if (S[i] != S[i + 1]) {
        if (S.size() == 2) {
          temp += 2;
          S.erase(i, 2);
          break;
        }
        S.erase(i, 2);
        cerr << S << endl;
        i -= 1;
        temp += 2;
      }
    }
    if (temp == 0) {
      break;
    }
    ans += temp;
  }
  cout << ans << endl;
  return 0;
}
