#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<pair<int, char>> ar;
  int l = 0;
  char start = s[0];
  for (auto& i : s) {
    if (i == start)
      l++;
    else {
      ar.push_back({l, start});
      l = 1;
      start = i;
    }
  }
  ar.push_back({l, start});
  long sum = 0;
  int n = ar.size();
  start = ar[0].second;
  for (int i = 0; i < n - 1; i++) {
    if (ar[i].second == ar[i + 1].second) {
      ar[i + 1].first += ar[i].first;
      continue;
    }
    sum += 2 * min(ar[i].first, ar[i + 1].first);
    int tmp =
        max(ar[i].first, ar[i + 1].first) - min(ar[i].first, ar[i + 1].first);
    if (tmp == 0) {
      i++;
      continue;
    }
    ar[i + 1].first = tmp;
    ar[i + 1].second = max(ar[i].first, ar[i + 1].first) == ar[i].first
                           ? ar[i].second
                           : ar[i + 1].second;
  }
  cout << sum;
  return 0;
}
