#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int p = 0;
  int n = 0;
  for (int i = 1; i < s.length(); ++i) {
    if (s[p] != s[i]) {
      s[p] = 'x';
      s[i] = 'x';
      while (p >= 0) {
        p--;
        if (s[p] != 'x') {
          break;
        }
      }
      i++;
      if (p == -1) p = i;
      ++n;
    } else {
      if (p == i - 1) {
        p++;
      } else {
        p = i;
      }
    }
  }
  cout << n * 2;
  return 0;
}
