#include <bits/stdc++.h>
using namespace std;
const long long mod = (1e9) + 7;
const double pi = acos(-1);
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void solve() {
  int n, i;
  string s;
  cin >> s;
  n = s.length();
  vector<pair<int, int> > v;
  int ch = s[0], ct = 1;
  for (i = 1; i < n; i++) {
    if (ch != s[i]) {
      v.push_back({ch, ct});
      ct = 1;
      ch = s[i];
    } else
      ct++;
  }
  v.push_back({ch, ct});
  n = v.size();
  if (n % 2 == 0) {
    cout << "0";
    return;
  }
  int l, r;
  i = n / 2;
  if (v[i].second == 1) {
    cout << "0";
    return;
  }
  int ans = v[i].second + 1;
  l = i - 1;
  r = i + 1;
  while (l >= 0 && r < n) {
    if (v[l].first != v[r].first) {
      cout << "0";
      return;
    }
    if (v[l].second + v[r].second < 3) {
      cout << "0";
      return;
    }
    l--;
    r++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
