#include <bits/stdc++.h>
using namespace std;
int get_ans(vector<pair<char, int>>& vec, int index) {
  int len = vec.size();
  int l = index - 1;
  int r = index + 1;
  if (vec[index].second < 2) return 0;
  while (l >= 0 && r < len) {
    if ((vec[l].first == vec[r].first) &&
        (vec[l].second + vec[r].second >= 3)) {
      l--;
      r++;
    } else {
      return 0;
    }
  }
  return vec[index].second + 1;
}
int main() {
  string s;
  vector<pair<char, int>> vec;
  cin >> s;
  s += " ";
  int sum = 1, i = 1;
  int curr_char = s[0];
  while (i < s.length()) {
    if (s[i] == s[i - 1]) {
      sum++;
    } else {
      vec.push_back(make_pair(curr_char, sum));
      curr_char = s[i];
      sum = 1;
    }
    i++;
  }
  if (vec.size() % 2 == 0)
    cout << 0 << endl;
  else
    cout << get_ans(vec, vec.size() / 2);
  return 0;
}
