#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char p = 's';
  int num = 0, n = s.size(), pi = 0, f = 1;
  for (int i = 0; i < n; i++) {
    if (s.at(i) != p && p != 's') {
      s.at(pi) = '-';
      s.at(i) = '-';
      num++;
      if (f) {
        i++;
        if (i >= n) break;
        pi = i;
        p = s.at(i);
        continue;
      }
      while (s.at((pi < 0 ? 0 : pi)) == '-' && pi >= 0) pi--;
      if (pi == -1) {
        i++;
        if (i >= n) break;
        pi = i;
        p = s.at(i);
        continue;
      } else
        p = s.at(pi);
      continue;
    }
    if (s.at(pi) != '-') f = 0;
    p = s.at(i);
    pi = i;
  }
  cout << num * 2 << endl;
}
