A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.

A substring s[l … r] (1 ≤ l ≤ r ≤ |s|) of a string s = s_{1}s_{2} … s_{|s|} is the string s_{l}s_{l + 1} … s_{r}.

Anna does not like palindromes, so she makes her friends call her Ann. She also changes all the words she reads in a similar way. Namely, each word s is changed into its longest substring that is not a palindrome. If all the substrings of s are palindromes, she skips the word at all.

Some time ago Ann read the word s. What is the word she changed it into?

Input

The first line contains a non-empty string s with length at most 50 characters, containing lowercase English letters only.

Output

If there is such a substring in s that is not a palindrome, print the maximum length of such a substring. Otherwise print 0.

Note that there can be multiple longest substrings that are not palindromes, but their length is unique.

Examples

Input

mew


Output

3


Input

wuffuw


Output

5


Input

qqqqqqqq


Output

0

Note

"mew" is not a palindrome, so the longest substring of it that is not a palindrome, is the string "mew" itself. Thus, the answer for the first example is 3.

The string "uffuw" is one of the longest non-palindrome substrings (of length 5) of the string "wuffuw", so the answer for the second example is 5.

All substrings of the string "qqqqqqqq" consist of equal characters so they are palindromes. This way, there are no non-palindrome substrings. Thus, the answer for the third example is 0.
import java.io.IOException;
import java.awt.color.*;
import java.util.*;
import java.math.*;
import java.io.*;
import java.util.InputMismatchException;	

@SuppressWarnings("unused")
public class main {	String g="";int c=0;int M=1000000000+7;
	public static void main(String[] args) {
                new main().solve();
                                  }
            public void solve() {
         
            	String s=sc.next();
            	StringBuilder sb=new StringBuilder(s);
            	sb.reverse();
            	if(!sb.toString().equals(s)) {
            		System.out.println(s.length());
            	}
            	else {
            	for(int i=0;i<s.length();i++) {
            		if(s.charAt(i)!=s.charAt(0))
            			c++;
            	}
            	if(c==0)
            		System.out.println(0);
            	else
            		System.out.println(s.length()-1);
            	}
            	
            	
          }
            
            	
            	
            static final int MAXN = 100001;
       	 
        	// stores smallest prime factor for every number
        	static int spf[] = new int[MAXN];
        	 
        	// Calculating SPF (Smallest Prime Factor) for every
        	// number till MAXN.
        	// Time Complexity : O(nloglogn)
        	static void sieve()
        	{
        	    spf[1] = 1;
        	    for (int i=2; i<MAXN; i++)
        	 
        	        // marking smallest prime factor for every
        	        // number to be itself.
        	        spf[i] = i;
        	 
        	    // separately marking spf for every even
        	    // number as 2
        	    for (int i=4; i<MAXN; i+=2)
        	        spf[i] = 2;
        	 
        	    for (int i=3; i*i<MAXN; i++)
        	    {
        	        // checking if i is prime
        	        if (spf[i] == i)
        	        {
        	            // marking SPF for all numbers divisible by i
        	            for (int j=i*i; j<MAXN; j+=i)
        	 
        	                // marking spf[j] if it is not 
        	                // previously marked
        	                if (spf[j]==j)
        	                    spf[j] = i;
        	        }
        	    }
        	}
        	 
        	// A O(log n) function returning primefactorization
        	// by dividing by smallest prime factor at every step
        	static Vector<Integer> getFactorization(int x)
        	{
        	    Vector<Integer> ret = new Vector<>();
        	    while (x != 1)
        	    {
        	        ret.add(spf[x]);
        	        x = x / spf[x];
        	    }
        	    return ret;
        	}
        	 
            int d, x, y;
            void extendedEuclid(int A, int B) {
                if(B == 0) {
                    d = A;
                    x = 1;
                    y = 0;
                }
                else {
                    extendedEuclid(B, A%B);
                    int temp = x;
                    x = y;
                    y = temp - (A/B)*y;
                }
            }
            static final int MAX_SIZE = 1000001;
            // isPrime[] : isPrime[i] is true if number is prime 
            // prime[] : stores all prime number less than N
            // SPF[] that store smallest prime factor of number
            // [for Exp : smallest prime factor of '8' and '16'
            // is '2' so we put SPF[8] = 2 , SPF[16] = 2 ]
            static Vector<Boolean>isprime = new Vector<>(MAX_SIZE);
            static Vector<Integer>prime = new Vector<>();
            static Vector<Integer>SPF = new Vector<>(MAX_SIZE);
              
            // method generate all prime number less then N in O(n)
            static void manipulated_seive(int N)
            {
                // 0 and 1 are not prime
                isprime.set(0, false);
                isprime.set(1, false);
                 
                // Fill rest of the entries
                for (int i=2; i<N ; i++)
                {
                    // If isPrime[i] == True then i is
                    // prime number
                    if (isprime.get(i))
                    {
                        // put i into prime[] vector
                        prime.add(i);
              
                        // A prime number is its own smallest
                        // prime factor
                        SPF.set(i,i);
                    }
              
                    // Remove all multiples of  i*prime[j] which are
                    // not prime by making isPrime[i*prime[j]] = false
                    // and put smallest prime factor of i*Prime[j] as prime[j]
                    // [ for exp :let  i = 5 , j = 0 , prime[j] = 2 [ i*prime[j] = 10 ]
                    // so smallest prime factor of '10' is '2' that is prime[j] ]
                    // this loop run only one time for number which are not prime
                    for (int j=0;
                         j < prime.size() &&
                         i*prime.get(j) < N && prime.get(j) <= SPF.get(i);
                         j++)
                    {
                        isprime.set(i*prime.get(j),false);
              
                        // put smallest prime factor of i*prime[j]
                        SPF.set(i*prime.get(j),prime.get(j)) ;
                    }
                }
            }
            

            int modularExponentiation(long x,long n)
            {
                if(n==0)
                    return 1;
                else if(n%2 == 0)        //n is even
                    return modularExponentiation((x*x),n/2);
                else                             //n is odd
                    return (int) ((x*modularExponentiation((x*x),(n-1)/2)));

            }
            
            
            
         
            int modularExponentiation(long x,long n,long M)
            {
                if(n==0)
                    return 1;
                else if(n%2 == 0)        //n is even
                    return modularExponentiation((x*x)%M,n/2,M);
                else                             //n is odd
                    return (int) ((x*modularExponentiation((x*x)%M,(n-1)/2,M))%M);

            }
            
            
            
            
            
            public int bfs(HashSet<Integer>[] adil,int n){
                int c=0;
                int[] shortdis=new int[n+1];
                Arrays.fill(shortdis,(int)1e5);
                LinkedList<Integer> queue=new LinkedList<Integer>();
                queue.add(1);
                shortdis[1]=0;
                while(queue.size()!=0){
                       int cc=queue.removeFirst();
                       Iterator<Integer> it=adil[cc].iterator();
                       while(it.hasNext()){
                              int f=it.next();
                              if(shortdis[f]==1e5){
                                     shortdis[f]=shortdis[cc]+1;
                                     queue.add(f);
                              }
                       }
                }
                return(shortdis[n]);
         }         
            
          /*  boolean[] sieveOfEratosthenes(int n)
            {
            	
                // (a / b) % m = (a % m * b^(m - 2) % m) % mCreate a boolean array "prime[0..n]" and initialize
                // all entries it as true. A value in prime[i] will
                // finally be false if i is Not a prime, else true.
                boolean prime[] = new boolean[n+1];
                for(int i=0;i<n;i++)
                    prime[i] = true;
                 
                for(int p = 2; p*p <=n; p++)
                {
                    // If prime[p] is not changed, then it is a prime
                    if(prime[p] == true)
                    {
                        // Update all multiples of p
                        for(int i = p*2; i <= n; i += p)
                            prime[i] = false;
                    }
                }
                 
                // Print all prime numbers
               return prime;
            }
            
   /*         void DFS(int v,boolean visited[])
    {
        // Mark the current node as visited and print it
        visited[v] = true;
        System.out.print(v+" ");
 
        // Recur for all the vertices adjacent to this vertex
        Iterator<Integer> i = adj[v].listIterator();
        while (i.hasNext())
        {
            int n = i.next();
            if (!visited[n])
                DFS(n, visited);
        }
    }*/
    /*static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        
        // nC0 is 1
        C[0] = 1;  
      
        for (int i = 1; i <= n; i++)
        {
            // Compute next row of pascal 
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j-1];
        }
        return C[k];
    }*/
         
          FastReader sc=new FastReader();
static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }}