#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int n = S.size();
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  unsigned int A[100100] = {0};
  A[0] = 1;
  int count = 0;
  for (int i = 1; i < n; ++i) {
    if (S[i - 1] != S[i]) {
      ++count;
    }
    ++A[count];
  }
  ++count;
  if (count % 2) {
    A[count] = 1 << 30;
    ++count;
  }
  int ans = 0;
  for (int i = 1; i < count; i += 2) {
    ans += min(A[i - 1], A[i]);
  }
  cout << ans * 2 << endl;
  return 0;
}
