#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
  string s;
  cin >> s;
  deque<char> d(s.begin(), s.end());
  int ans = 0;
  while (d.size() >= 2) {
    int idx = 1;
    vector<int> indeces;
    while (idx < d.size()) {
      if (d[idx] != d[idx - 1]) {
        indeces.push_back(idx);
        idx += 2;
      } else {
        idx++;
      }
    }
    if (indeces.empty()) {
      break;
    }
    for (auto idx : indeces) {
      d.erase(d.begin() + idx);
      d.erase(d.begin() + idx - 1);
      ans += 2;
    }
  }
  cout << ans << '\n';
  return 0;
}
