#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.length();
  vector<int> tmp(len, 0);
  vector<bool> deleted(len, false);
  pair<int, char> prev = make_pair(0, s[0]);
  for (int i = 1; i < len; ++i) {
    if (prev.first >= 0 && prev.second != s[i]) {
      tmp[i] = tmp[i - 1] + 2;
      deleted[i] = true;
      deleted[i - 1] = true;
      for (int j = prev.first - 1; j >= 0; --j) {
        if (!deleted[j])
          prev = make_pair(j, s[j]);
        else if (j == 0)
          prev = make_pair(-1, '-');
      }
    } else {
      tmp[i] = tmp[i - 1];
      prev = make_pair(i, s[i]);
    }
  }
  cout << tmp[len - 1] << '\n';
}
