#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int r = 0;
  int c = 0;
  char top = s.at(0);
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == top)
      r++;
    else if (r > 0)
      c++;
  }
  cout << c * 2 << endl;
}
