#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  string s;
  cin >> s;
  long long n = s.size();
  long long b = 0, e = n - 1;
  while (true) {
    long long delta = 0;
    if (s[b] != s[e]) {
      cout << 0;
      return 0;
    }
    while (s[b] == s[e] && b <= e) {
      delta++;
      b++;
    }
    long long p = 0;
    while (s[b - delta] == s[e] && b <= e) {
      p++;
      e--;
    }
    delta += p;
    if (delta < 3 && b <= e) {
      cout << 0;
      return 0;
    }
    if (b > e) {
      if (delta == 1) {
        cout << 0;
        return 0;
      }
      cout << delta + 1;
      return 0;
    }
  }
}
