#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count, i, n1, ans, temp;
  string s, new_str;
  cin >> s;
  n = s.size();
  vector<int> new_counts;
  new_str = s[0];
  count = 1;
  for (i = 1; i < n; i++) {
    if (s[i] == s[i - 1])
      count++;
    else {
      new_counts.push_back(count);
      count = 1;
      new_str += s[i];
    }
  }
  new_counts.push_back(count);
  n1 = new_str.size();
  ans = 0;
  for (i = 0; i < (n1 - 1); i++) {
    temp = min(new_counts[i], new_counts[i + 1]);
    ans += temp;
    new_counts[i] -= temp;
    new_counts[i + 1] -= temp;
    if ((i + 2) < n1) new_counts[i + 2] += new_counts[i];
    if ((i + 3) < n1) new_counts[i + 3] += new_counts[i + 1];
  }
  cout << (2 * ans) << endl;
  return 0;
}
