#include <bits/stdc++.h>
using namespace std;
template <class T>
void maxi(T& a, T b) {
  a = max(a, b);
  return;
}
template <class T>
void mini(T& a, T b) {
  a = min(a, b);
  return;
}
bool is_prime(int a) {
  if (a == 2) return true;
  if (!(a & 1) || a == 1) return false;
  for (int i = 3; i * i <= a; i += 2)
    if (!(a % i)) return false;
  return true;
}
bool is_prime(long long a) {
  if (a == 2) return true;
  if (!(a & 1) || a == 1) return false;
  for (long long i = 3; i * i <= a; i += 2)
    if (!(a % i)) return false;
  return true;
}
int gcd(int a, int b) {
  while (b) {
    int mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int binpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
int binpow(int a, int b, int MODULO) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MODULO;
    }
    a *= a;
    a %= MODULO;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b) {
    long long mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
string binary(int N) {
  if (!N) return "0";
  string bin = "";
  while (N) {
    bin += '0' + (N & 1);
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
string binary(long long N) {
  if (!N) return "0";
  string bin = "";
  while (N) {
    bin += '0' + (N & 1);
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
const int INF = 2147483547;
const int MODULO = 1000000007;
const int _MODULO = 998244353;
const long long INF64 = 9223372036854775707;
const long long MODULO64 = 1000000007;
const long long _MODULO64 = 998244353;
const double epsilon = 10e-6;
const double PI = acos(-1);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const bool b) { return (b ? "true" : "false"); }
string to_string(const char* s) { return to_string((string)s); }
string to_string(const char c) {
  string s = "'";
  s += c;
  s += "'";
  return s;
}
template <class T, class U>
string to_string(const pair<T, U>& p) {
  string s = "(";
  s += to_string(p.first);
  s += ", ";
  s += to_string(p.second);
  s += ")";
  return s;
}
template <class T>
string to_string(const T& a) {
  bool first = true;
  string s = "{";
  for (const auto& x : a) {
    if (!first) {
      s += ", ";
    }
    first = false;
    s += to_string(x);
  }
  s += "}";
  return s;
}
void debug_out() { cerr << '\n'; }
template <class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
  cerr << ' ' << to_string(head);
  debug_out(tail...);
}
bool is_palindrome(vector<pair<char, int>>& s) {
  int n = s.size();
  for (int i = 0; i < (n >> 1); ++i) {
    if (s[i].first != s[n - i - 1].first ||
        s[i].second + s[n - i - 1].second < 3)
      return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int len = s.length();
  vector<pair<char, int>> res;
  for (int i = 0; i < len; ++i) {
    if (!i) {
      res.emplace_back(s[i], 1);
      continue;
    }
    if (s[i] == s[i - 1]) {
      ++(res.back()).second;
      continue;
    }
    res.emplace_back(s[i], 1);
  }
  int n = res.size();
  if (!is_palindrome(res) || res[n >> 1].second == 1) {
    cout << 0 << '\n';
    return 0;
  }
  cout << res[n >> 1].second + 1 << '\n';
  return 0;
}
