#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  vector<pair<char, int> > v;
  char cur = s[0];
  int count = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == cur)
      count++;
    else {
      v.push_back({cur, count});
      cur = s[i];
      count = 1;
    }
  }
  v.push_back({cur, count});
  int ans = 0;
  if (!(v.size() & 1))
    ans = 0;
  else {
    int cur = v.size() / 2;
    int left = cur - 1, right = cur + 1, n = v.size();
    ans = v[cur].second + 1;
    ans = ans >= 3 ? ans : 0;
    while (left >= 0 && right < n) {
      if (v[left].first == v[right].first &&
          v[left].second + v[right].second >= 3)
        ;
      else {
        ans = 0;
        break;
      }
      left--, right++;
    }
  }
  cout << ans;
}
