#include <bits/stdc++.h>

using namespace std;

const int MAX = 2 * 100000;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  string a;
  cin>>a;

  long long i = 0, j = a.length()-1;
  bool GoFuther = false;

  while(i < j) {

    GoFuther = true;

    if(a[i] == a[j]) {
      i++;
      j--;
      continue;
    }
    // ping first
    for(long long k = i+1; k < j ; k++) {
      if(a[k] == a[j]) {
        j--;
        GoFuther = false;
        break;
      }
    }
    if(GoFuther)
    {
      for(long long k = j-1 ; k > i ; k-- ) {
        if(a[k] == a[i]) {
          i++;
          GoFuther = false;
          break;
        }
      }

      if(GoFuther) break;

    }

  }

  cout<<++j-i;

  return 0;
}