#include <bits/stdc++.h>
using namespace std;
int length, m;
char a[300000 + 10];
int b[300000 + 10];
char balls[300000 + 10];
int main() {
  scanf("%s", balls + 1);
  length = strlen(balls + 1);
  for (int i = 1; i <= length; i++) {
    if (balls[i] != balls[i - 1]) {
      m++;
      a[m] = balls[i];
      b[m] = 1;
    } else
      b[m]++;
  }
  if (m % 2 == 0) return printf("0"), 0;
  for (int i = 1; i <= m / 2; i++) {
    if (a[i] != a[m - i + 1]) return printf("0"), 0;
    if (b[i] + b[m - i + 1] < 3) return printf("0"), 0;
  }
  if (b[m / 2 + 1] == 1) return printf("0"), 0;
  printf("%d", b[m / 2 + 1] + 1);
  return 0;
}
