s = str(input())
if s != s[::-1]:
print(len(s))
else:
if len(set(s)) == 1:
print(0)
else:
print(len(s)-1)
#include<bits/stdc++.h>
using namespace std;
typedef int li;
typedef long long int ll;
typedef unsigned long long int ul;
typedef double db;
//---------------------------------------------------------------------------------
typedef vector < li > vli;
typedef vector < ll > vll;
typedef set < li > sli;
typedef set < ll > sll;
typedef pair < pair<li, li>, li> pli;
typedef pair < ll, ll > pll;
typedef map < li,li > mli;
typedef map < ll,ll > mll;
typedef vector < pair < li, li > > vpi;
typedef vector < pair < ll, ll > > vpl;
typedef priority_queue<li> pqi;
typedef priority_queue<ll> pql;
//----------------------------------------------------------------------------------
#define Fast ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define tc int t;cin>>t;while(t--)
#define inp_(a,n) for(int i=0; i<n ;i++) cin>>a[i];
#define loop_(a,n) for(int i=0; i<n ;i++)
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
//----------------------------------------------------------------------------------
//-----------------------USER DEFINED FUNC--------------------------------//
/*
//Prime check
bool isPrime(int n)
{
if (n<2) return false;
if (n<=3) return true;
if (!(n%2) || !(n%3)) return false;
for (int i=5; i*i<=n; i+=6)
if (!(n%i) || !(n%(i+2))) return false;
return true;
}
//Greatest common divisor — GCD
ll gcd(ll a, ll b)
{
if (b==0) return a;
else return gcd(b, a%b);
}
//Least common multiple — LCM
int lcm(int a, int b)
{
return a*b/gcd(a,b);
}
//--------------------------------------Sieve_Of_Eratosthenes------------------------------//
const ll x=10000000+5;
bool prime[x];
vector<ll> kthprime;
void seive(){
memset(prime,true,sizeof(prime));
prime[0]=prime[1]=false;
for(ll i=2; i*i<=x; i++){
if(prime[i]){
for(ll j=i*i; j<=x; j+=i){
prime[j]=false;
}
}
}
for(ll i=2; i<=x; i++) {
if(prime[i]) kthprime.push_back(i);
}
// for(auto u:kthprime) cout<<u<<" ";
}
void SieveOfEratosthenes(int n)
{
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++)
{
if (prime[p] == true)
{
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
// Print all prime numbers
for (int p = 2; p <= n; p++)
if (prime[p])
cout << p << " ";
}
//----------------------------------------------------------------------------------------//
ll findGCD(ll a[], ll n)//over an array
{
ll result = a[0];
for (int i = 1; i < n; i++)
{
result = gcd(a[i], result);
if(result == 1)
{
return 1;
}
}
return result;
}
//-----------------------------------------------------------------------------------------//
ll ub(vector<ll>&v, ll R)
{
ll left=0, right=v.size()-1, mid;
while(left<=right)
{
mid=(left+right)/2;
if(v[mid]>R) right=mid-1;
else left=mid+1;
}
return left;
}
ll lb(vector<ll>&v, ll R)
{
ll left=0, right=v.size()-1, mid;
while(left<=right)
{
mid=(left+right)/2;
if(v[mid]>=R) right=mid-1;
else left=mid+1;
}
return left;
}
//-----------------------------------------------------------------------------------------//
*\
///////////////////////////*****STARTING POINT*****/////////////////////////////////
void solve(){
string s,cs;
cin>>s;
cs = s;
sort(cs.begin(),cs.end());
if(cs[0]==cs[s.length()-1]) cout<<0;
else if(s[0]!=s[s.length()-1]) cout<<s.length();
else{
int f=0,l=s.length()-1,c=0;
for(int i=0; i<s.length()/2; i++){
if(s[f]!=s[l]) {c=1; break;}
f++;l--;
}
if(c) cout<<s.length();
else cout<<s.length()-1;
}
}
int main(){
Fast
//tc
solve();
}
///////////////////////////*****END OF CODE*****////////////////////////////////////
1358B - Maria Breaks the Self-isolation | 828A - Restaurant Tables |
1735A - Working Week | 1735D - Meta-set |
1735B - Tea with Tangerines | 1735C - Phase Shift |
1321C - Remove Adjacent | 281B - Nearest Fraction |
1043A - Elections | 1598C - Delete Two Elements |
1400C - Binary String Reconstruction | 1734D - Slime Escape |
1499A - Domino on Windowsill | 991A - If at first you don't succeed |
1196C - Robot Breakout | 373A - Collecting Beats is Fun |
965A - Paper Airplanes | 863E - Turn Off The TV |
630E - A rectangle | 1104A - Splitting into digits |
19C - Deletion of Repeats | 1550B - Maximum Cost Deletion |
1693A - Directional Increase | 735D - Taxes |
989A - A Blend of Springtime | 339C - Xenia and Weights |
608A - Saitama Destroys Hotel | 1342C - Yet Another Counting Problem |
548A - Mike and Fax | 109A - Lucky Sum of Digits |