#include <bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int n, cnt[200005][26], rcnt[200005][26];
string s, t, rt;

bool check(int x){
  int sum = 0;
  for(int i = 0; i < 26; ++i){
    if(cnt[x][i] < rcnt[n - x - 2][i]){return false;}
    sum += (cnt[x][i] - rcnt[n - x - 2][i]) % 2;
    if(sum > 1){return false;}
  }
  return true;
}

bool rcheck(int x){
  int sum = 0;
  for(int i = 0; i < 26; ++i){
    if(rcnt[x][i] < cnt[n - x - 2][i]){return false;}
    sum += (rcnt[x][i] - cnt[n - x - 2][i]) % 2;
    if(sum > 1){return false;}
  }
  return true;
}

int main(){
  cin >> s; n = s.size();
  int idx = 0;
  while(s[idx] == s[n - idx - 1] && idx < n - idx - 1){++idx;}
  t = s.substr(idx, n - 2 * idx);
  n = t.size();
  if(n == 0){cout << 1 << endl; return 0;}
  for(int i = 0; i < n; ++i){
    if(!i){cnt[i][t[i] - 'a'] = 1; continue;}
    for(int c = 0; c < 26; ++c){
      cnt[i][c] = cnt[i - 1][c];
    }
    ++cnt[i][t[i] - 'a'];
  }
  rt = t;
  reverse(rt.begin(), rt.end());
  for(int i = 0; i < n; ++i){
    if(!i){rcnt[i][rt[i] - 'a'] = 1; continue;}
    for(int c = 0; c < 26; ++c){
      rcnt[i][c] = rcnt[i - 1][c];
    }
    ++rcnt[i][rt[i] - 'a'];
  }
  for(int i = 0; i < n - 1; ++i){
    if(check(i) || rcheck(i)){cout << i + 1 << endl; return 0;}
  }
  int sum = 0;
  for(int i = 0; i < 26; ++i){
    sum += cnt[n - 1][i] % 2;
    if(sum > 1){return 0;}
  }
  cout << n << endl;
  return 0;
}