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 \ldots r]$$$ ($$$1 \leq l \leq r \leq |s|$$$) of a string $$$s = s_{1}s_{2} \ldots s_{|s|}$$$ is the string $$$s_{l}s_{l + 1} \ldots 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?

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

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.

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$$$.

using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static public bool IsPalindrom(string str)
        {
            int c = str.Length / 2;
            for (int i = 0; i < c; i++)
            {
                if (str[i] != str[str.Length - 1 - i])
                    return false;
            }
            return true;
        }
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            if (!IsPalindrom(str))
                Console.WriteLine(str.Length);
            else if (str.Distinct().Count() > 1)
                Console.WriteLine(str.Length - 1);
            else Console.WriteLine(0);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Olympiad
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] word = Console.ReadLine().ToCharArray();
            int len = 0;
            if(word.Length%2==0)
            {
                len = word.Length / 2;
            }
            else
            {
                len = word.Length / 2 + 1;
            }
            bool pal = true;
            for (int i = 0; i < len; i++)
            {
                if(word[i]!=word[word.Length-i-1])
                {
                    pal = false;
                    break;
                }
            }

            if(!pal)
            {
                Console.WriteLine(word.Length);
            }
            else
            {
                bool oneSymb = true;
                for (int i = 0; i < word.Length-1; i++)
                {
                    if (word[i] != word[i+1])
                    {
                        oneSymb = false;
                        break;
                    }
                }
                if(!oneSymb)
                {
                    Console.WriteLine(word.Length-1);
                }
                else
                {
                    Console.WriteLine(0);
                }
            }
        }
    }
}

using System;
using System.Linq;

namespace CSharp
{
    class _981A
    {
        public static void Main()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.Distinct().Count() == 1 ? 0 : s.Length - (s == new string(s.Reverse().ToArray()) ? 1 : 0));
        }
    }
}

using System;
using System.Linq;

namespace Avito_Code_Challenge_2018
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            for (int i = 0; i < str.Length; i++)
            {
                var pol = new string(str.Substring(i).Reverse().ToArray());
                if (!str.Substring(i).Equals(pol))
                {
                    Console.WriteLine(str.Length-i);
                   // Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("0");
            //
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;

namespace Egor
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string inp = Console.ReadLine ();
			int n = inp.Length;
			string pal = "";
			int res = 55;

			for (int i = 0; i < n; i++) {
				for (int j = n - 1 - i; j >= 0; j--) pal += inp [j].ToString();
				if (inp.Substring(0, n - i) != pal) {
					res = i;
					break;
				}
				pal = "";
			}
			if (res == 55) Console.WriteLine (0);
			else Console.WriteLine (n - res);
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int result = 0;

            string s = Console.ReadLine();

            for (int i = 0; i < s.Length; i++)
            {
                var ss = s.Substring(0, s.Length - i);
                var r = new String(ss.ToCharArray().Reverse().ToArray());

                if (ss != r)
                {
                    result = ss.Length;
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Antipalindrom
{
    class Program
    {
        static bool IsPalindrom(string s)
        {
            int n = s.Length;
            bool isPalind=true;
            for (int i = 0; i < n / 2 && isPalind; i++)
            {
                if (s[i]!=s[n-i-1])
                {
                    isPalind = false;
                }
            }
            return isPalind;
        }

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int maxLength = 0;
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = s.Length - 1; j > i; j--)
                {
                    int len=j-i+1;
                    if (len > maxLength && !IsPalindrom(s.Substring(i, len))) maxLength = len;
                }
            }

            Console.Write(maxLength);
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Antipalindrome
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            string s = reader.ReadLine();

            bool ok = true;
            for (int i = 0, j = s.Length - 1; i < j; i++,j--)
            {
                if (s[i] != s[j])
                {
                    ok = false;
                    break;
                }
            }
            if (!ok)
                return s.Length;

            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] != s[i - 1])
                    return s.Length - 1;
            }

            return 0;
        }
    }
}

using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            if (x != null)
                p.Out(x);
        }

        object Solve()
        {
            var s = Read();
            var max = 0;
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 1; j < s.Length - i + 1; j++)
                {
                    var s2 = s.Substring(i, j);
                    if (max < s2.Length && !IsPalindrom(s2))
                        max = s2.Length;
                }
            }

            return max;
        }

        bool IsPalindrom(string s)
        {
            for (int k = 0; k < s.Length / 2; k++)
            {
                if (s[k] != s[s.Length - k - 1])
                    return false;
            }

            return true;
        }
        void DFS(List<long>[] graph, List<List<long>> result, long current, bool[] visited)
        {
            visited[current] = true;
            foreach (var item in graph[current])
            {

            }
        }

        long CountAns(int pow, long k, long[] hopes, long[] fact, int addedOnes)
        {
            long res = 0;
            for (int i = 0; i <= pow; i++)
            {
                int realOnes = i + addedOnes;
                if (realOnes > 1000)
                    break;
                if (realOnes > 0 && hopes[realOnes] == k - 1)
                    res = (res + fact[pow] * fastpow(fact[i] * fact[pow - i] % commonMod, commonMod - 2)) % commonMod;
            }
            return res;
        }

        int CountOnes(int i)
        {
            int res = 0;
            while (i != 0)
            {
                if ((i & 1) == 1)
                    res++;
                i >>= 1;
            }
            return res;
        }

        long fastpow(long b, long x)
        {
            checked
            {
                if (x == 0)
                    return 1;
                if (x == 1)
                    return b;
                if (x % 2 == 0)
                    return fastpow(b * b % commonMod, x / 2);
                return b * fastpow(b, x - 1) % commonMod;
            }
        }
        int nod(int a, int b)
        {
            if (a < b)
                return nod(b, a);
            if (b == 0)
                return a;
            return nod(b, a % b);
        }

        class End
        {
            public long Val { get; set; }
            public bool Left { get; set; }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }

}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
 using System.Runtime.Remoting.Channels;
 using System.Text;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        private bool IsPalindrome(string s, int start, int end)
        {
            for (var i = start; i <= (start + end) / 2; i++) {
                if (s[i] != s[end - (i - start)])
                    return false;
            }

            return true;
        }

        public void Solve()
        {
            var s = sr.NextString();
            var max = 0;
            for (var i = 0; i < s.Length; i++) {
                for (var j = i + 1; j < s.Length; j++) {
                    if (!IsPalindrome(s, i, j)) {
                        max = Math.Max(max, j - i + 1);
                    }
                }
            }

            sw.WriteLine(max);
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        static void main()
        {

        }

        private static int Nod(decimal n, decimal d)
        {
            n = Math.Abs(n);
            d = Math.Abs(d);
            while (d != 0 && n != 0)
            {
                if (n % d > 0)
                {
                    var temp = n;
                    n = d;
                    d = temp % d;
                }
                else break;
            }
            if (d != 0 && n != 0) return (int)d;
            return 0;
        }

        static int Count(string source, string key)
        {

            List<int> indices = new List<int>();

            int index = source.IndexOf(key, 0);

            while (index > -1)
            {
                indices.Add(index);
                index = source.IndexOf(key, index + key.Length);
            }

            return indices.Count();
        }

        private static string Reverse(string s)
        {
            string s2 = "";

            for (int i = s.Length - 1; i >= 0; i--)
            {
                s2 += s[i];
            }

            return s2;
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            string s = Console.ReadLine(), s1 = s, s2 = "", s3 = s, s4 = "";
            for (int i = s.Length - 1; i >= 0; i--)
            {
                s2 += s[i];
            }

            s4 = s2;

            while (s1.Equals(s2) && s3.Equals(s4) && s1.Length > 0)
            {
                s1 = s1.Substring(0, s1.Length - 1);
                s2 = s2.Substring(1, s2.Length - 1);
                s3 = s3.Substring(1, s3.Length - 1);
                s4 = s4.Substring(0, s4.Length - 1);
            }

            Console.WriteLine(s1.Length);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bla
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(solve(s));
        }

        static int solve(string s)
        {
            if (s == "")
                return 0;
            if (!ispalindrome(s))
                return s.Length;
            s = s.Substring(0, s.Count() - 1);
            return solve(s);
        }

        static bool ispalindrome(string s)
        {
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != s[s.Length - 1 - i])
                    return false;
            }
            return true;
        }
    }
}

using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            String input = Console.ReadLine();

            Int32 currentLength = input.Length;
            while (currentLength > 1)
            {
                for (Int32 i = 0; i <= input.Length - currentLength; i++)
                {
                    if (!IsPalindrome(input, i, currentLength))
                    {
                        Console.WriteLine(currentLength);
                        return;
                    }
                }
                currentLength--;
            }
            Console.WriteLine(0);
        }

        private static Boolean IsPalindrome(String str, Int32 startIndex, Int32 length)
        {
            for (Int32 i = startIndex; i <= startIndex + length / 2; i++)
            {
                 if (str[i] != str[startIndex + length - i - 1])
                    return false;
            }
            return true;
        }
    }
}

using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine(), s1 = s, s2 = "", s3 = s, s4 = "";
            for(int i = s.Length - 1; i >= 0; i--)
                s2 += s[i];
            s4 = s2;
            while (s1.Equals(s2) && s3.Equals(s4) && s1.Length > 0)
            {
                s1 = s1.Substring(0, s1.Length - 1);
                s2 = s2.Substring(1, s2.Length - 1);
                s3 = s3.Substring(1, s3.Length - 1);
                s4 = s4.Substring(0, s4.Length - 1);
            }
            Console.WriteLine(s1.Length);
        }
    }
}

using System;

namespace CF_981_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            // Костылик
            if (str.Length == 2)
            {
                if (str[0] == str[1])
                    Console.WriteLine(0);
                else
                    Console.WriteLine(2);
                return;
            }

            // Проходит 40 тестов без кода перед этой строкой

            for (int i = 0; i < str.Length-2; i++)
            {
                for (int j = str.Length-i; j > 1; j--)
                {
                    if (!IsPalindrom(str.Substring(i, j)))
                    {
                        Console.WriteLine(j);
                        return;
                    }
                }
            }
            Console.WriteLine(0);
        }

        private static bool IsPalindrom(string v)
        {
            int i = 0;
            int j = v.Length - 1;
            while (i<j)
            {
                if (v[i] != v[j]) return false;
                i++; j--;
            }
            return true;
        }
    }
}

using System;

namespace Apalindrom
{
    class Program
    {
        static void Main()
        {
            string S = Console.ReadLine();
            if (S.Length == 0)
                Console.Write("0");
            else
            {
                int min = 0;
                int max = S.Length - 1;
                bool p = false;
                while (true)
                {
                    if (min > max)
                    {
                        p = true;
                        break;
                    }
                    char a = S[min];
                    char b = S[max];
                    if (char.ToLower(a) != char.ToLower(b))
                    {
                        p = false;
                        break;
                    }
                    min++;
                    max--;
                }

                int k = S[0];
                bool s = false;
                for (int i = 0; i < S.Length; i++)
                {
                    if (S[i] != S[0])
                        s = true;
                }

                if (!p)
                    Console.WriteLine(S.Length);
                else if (p && !s)
                    Console.WriteLine("0");
                else if (p && s)
                    Console.WriteLine(S.Length - 1);
            }
        }
    }
}

using System;
namespace SolutionsForCodeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string MyString = Console.ReadLine();
            if (!IsPalindrom(MyString))
            {
                Console.WriteLine(MyString.Length);
                return;
            }
            else
            {
                MyString = MyString.Remove(0, 1);
                if (!IsPalindrom(MyString))
                {
                    Console.WriteLine(MyString.Length);
                    return;
                }
                else Console.WriteLine("0");
            }
        }
        static bool IsPalindrom(string s)
        {
            var Array = s.ToCharArray();
            var ReversedArray = (char[])Array.Clone();
            System.Array.Reverse(ReversedArray);
            bool IsGood = true;
            for (int i = 0; i < Array.Length; i++)
            {
                if (Array[i] != ReversedArray[i])
                {
                    IsGood = false;
                }
            }
            return IsGood;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforce
{
    class Program
    {
        static int Main(string[] args)
        {
            string input = Console.ReadLine();
            for (int i = 0; i < input.Length; i++)
            {
                string temp = input.Substring(i);
                if (!PaliCheck(temp))
                {
                    Console.Write(temp.Length.ToString());
                    //Console.Read();
                    return 0;
                }
            }
            Console.Write(0);
            //Console.Read();
            return 0;
        }

        static bool PaliCheck(string input)
        {
            char[] inArr = input.ToCharArray();
            //Array.Reverse(inArr); //didn't work in Mono
            char[] temp = new char[inArr.Length];
            for (int i = 0, j = inArr.Length - 1; i < inArr.Length; i++, j--)
            {
                temp[j] = inArr[i];
            }
            string reversed = new string(temp);
            //Console.WriteLine("Input = " + input + "\n Revesed = " + reversed);
            if (input == reversed) return true;
            else return false;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            var s = ReadLine();
            int n = s.Length;
            for (int i = n; i >= 0; i--)
            {
                bool isPal = true;
                for (int j = 0; j < i; j++)
                {
                    if (s[j] != s[i - j - 1])
                    {
                        isPal = false;
                        break;
                    }
                }
                if (!isPal)
                {
                    Writer.WriteLine(i);
                    return;
                }
            }
            Writer.WriteLine(0);
        }

        public static void Solve()
        {
            SolveCase();

            /*var sw = Stopwatch.StartNew();*/

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

            /*sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);*/
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            Solve();
            /*Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();*/

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}

using System;

namespace CF_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            while (IsPalindrom(s) && s.Length > 0)
                s = s.Remove(s.Length - 1, 1);

            Console.WriteLine(s.Length);
        }

        static bool IsPalindrom(string s)
        {
            for (int i = 0; i < s.Length / 2; i++)
                if (s[i] != s[s.Length - i - 1])
                    return false;
            return true;
        }
    }
}

using System;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int n = 0;

            while (n<=s.Length)
            {
                for(int i = 0; i <= n; i++)
                {
                    if (!IsPalindrome(s.Substring(i, s.Length - n)))
                    {
                        Console.Write(s.Length - n);
                        return;
                    }
                }
                n++;
            }
            Console.Write(0);

        }

        private static bool IsPalindrome(string s)
        {
            for(int i = 0; i < s.Length / 2; i++)
            {
                if (s[i] != s[s.Length - 1 - i]) return false;
            }
            return true;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        static void main()
        {

        }

        private static int Nod(decimal n, decimal d)
        {
            n = Math.Abs(n);
            d = Math.Abs(d);
            while (d != 0 && n != 0)
            {
                if (n % d > 0)
                {
                    var temp = n;
                    n = d;
                    d = temp % d;
                }
                else break;
            }
            if (d != 0 && n != 0) return (int)d;
            return 0;
        }

        static int Count(string source, string key)
        {

            List<int> indices = new List<int>();

            int index = source.IndexOf(key, 0);

            while (index > -1)
            {
                indices.Add(index);
                index = source.IndexOf(key, index + key.Length);
            }

            return indices.Count();
        }

        private static string Reverse(string s)
        {
            string s2 = "";

            for (int i = s.Length - 1; i >= 0; i--)
            {
                s2 += s[i];
            }

            return s2;
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            string s = Console.ReadLine(), s1 = s, s2 = "", s3 = s, s4 = "";
            s = Reverse(s);

            s4 = s2;

            while (s1.Equals(s2) && s3.Equals(s4) && s1.Length > 0)
            {
                s1 = s1.Substring(0, s1.Length - 1);
                s2 = s2.Substring(1, s2.Length - 1);
                s3 = s3.Substring(1, s3.Length - 1);
                s4 = s4.Substring(0, s4.Length - 1);
            }

            Console.WriteLine(s1.Length);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    public sealed class Crown
    {
        public decimal Gem { get; set; }

        public decimal Weight { get; set; }

        public decimal Value { get; set; }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        static void main()
        {

            int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int n = arr[0];
            int k = arr[1];

            List<Crown> list = new List<Crown>();

            for (int i = 0; i < n; i++)
            {
                decimal[] data = Console.ReadLine().Split().Select(decimal.Parse).ToArray();

                decimal gem = data[0];
                decimal weight = data[1];

                decimal value = gem / weight;

                list.Add(new Crown { Gem = gem, Weight = weight, Value = value });
            }

            List<Crown> sortedList = list.OrderByDescending(x => x.Value).ThenBy(x => x.Weight).ToList();

            decimal start = 0;

            decimal end = 0;

            for (int i = 0; i < k; i++)
            {
                start += sortedList[i].Gem;

                end += sortedList[i].Weight;
            }

            if (end == 0)
            {
                end++;
            }

            if (start % 10 == 0 && end % 10 == 0)
            {
                start /= 10;
                end /= 10;
            }

            int nod = Nod(start, end);

            start /= nod;

            end /= nod;

            string res = start.ToString() + "/" + end.ToString();

            Console.WriteLine(res);

        }

        private static int Nod(decimal n, decimal d)
        {
            n = Math.Abs(n);
            d = Math.Abs(d);
            while (d != 0 && n != 0)
            {
                if (n % d > 0)
                {
                    var temp = n;
                    n = d;
                    d = temp % d;
                }
                else break;
            }
            if (d != 0 && n != 0) return (int)d;
            return 0;
        }

        static int Count(string source, string key)
        {

            List<int> indices = new List<int>();

            int index = source.IndexOf(key, 0);

            while (index > -1)
            {
                indices.Add(index);
                index = source.IndexOf(key, index + key.Length);
            }

            return indices.Count();
        }

        private static bool Check(string s)
        {
            char[] arr = s.ToCharArray();

            Array.Reverse(arr);

            string res = new string(arr);

            if (s == res)
            {
                return true;
            }

            else
            {
                return false;
            }
        }

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            string str = Console.ReadLine();
            int n = str.Length;
            bool pal = true;
            for (int i = str.Length - 1; i > str.Length / 2; i--)
            {
                if (str[i] != str[str.Length - i - 1])
                    pal = false;
            }
            if (!pal) { }
            else
            {
                while (pal && str.Length > 0)
                {
                    str = str.Substring(0, str.Length - 1);
                    for (int i = str.Length - 1; i >= str.Length / 2; i--)
                    {
                        if (str[i] != str[str.Length - i - 1])
                            pal = false;
                    }
                    n--;
                }
            }
            Console.WriteLine(n);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}

using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine(), s1 = s, s2 = "", s3 = s, s4 = "";
            for(int i = s.Length - 1; i >= 0; i--)
                s2 += s[i];
            s4 = s2;
            while (s1.Equals(s2) && s3.Equals(s4) && s1.Length > 0)
            {
                s1 = s1.Substring(0, s1.Length - 1);
                s2 = s2.Substring(1, s2.Length - 1);
                s3 = s3.Substring(1, s3.Length - 1);
                s4 = s4.Substring(0, s4.Length - 1);
            }
            Console.WriteLine(s1.Length);
            Console.WriteLine(s2);

        }
    }
}

using System;

namespace CF_981_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            for (int i = 0; i < str.Length-2; i++)
            {
                for (int j = str.Length-i; j > 1; j--)
                {
                    if (!IsPalindrom(str.Substring(i, j)))
                    {
                        Console.WriteLine(j);
                        return;
                    }
                }
            }
            Console.WriteLine(0);
        }

        private static bool IsPalindrom(string v)
        {
            int i = 0;
            int j = v.Length - 1;
            while (i<j)
            {
                if (v[i] != v[j]) return false;
                i++; j--;
            }
            return true;
        }
    }
}