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?


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

Difficulty: interview

Starter code:

Solutions:
s = input()
mx = 0
n = len(s)
for l in range(n):
    for r in range(l, n):
        if s[l:r+1] != s[l:r+1][::-1]:
            mx = max(mx, r - l + 1)
print(mx)

ans = 0
s = input()
n = len(s)
for i in range(n):
    for j in range(i + 1, n + 1):
        t = s[i:j]
        if t != t[::-1]:
            ans = max(ans, j- i)
print(ans)



import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

s=(input()).strip()

ans=0

for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        t=s[i:j]
        if t==t[::-1]: continue
        ans=max(ans,len(t))
print(ans)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May 27 20:07:20 2018

@st0rmbring3r
"""

word = input()
while word == word[::-1] and len(word)>0:
    word = word[:-1]

print(len(word))


a = input()

mm = 0
for i in range(len(a)):
    for j in range(i, len(a)):
        x = ""
        for xx in range(i, j + 1):
            x += a[xx]
        if x != x[::-1]:
            mm = max(mm, len(x))

print(mm)


s = input()
ans = 0
for i in range(len(s)):
  for j in range(i, len(s)):
    t = s[i:j+1]
    if t != "".join(list(reversed(t))):
      ans = max(ans, j-i+1)
print(ans)

# python3
from operator import eq


def is_palindrome(string):
    half = len(string) // 2 + 1
    return all(map(eq, string[:half], reversed(string)))


def main():
    string = input()
    first = string[0]

    if all(symbol == first for symbol in string):
        print(0)
    else:
        print(len(string) - 1 if is_palindrome(string) else len(string))


main()



s=input()
ans = 0
n=len(s)
for i in range(n):
  t=""
  for j in range(i,n):
    t+=s[j]
    if(t!=t[::-1]):
      ans=max(ans,len(t))
print(ans)



from sys import stdin, stdout

s = stdin.readline().strip()
ans = 0

for l in range(1, len(s) + 1):
    for i in range(len(s) - l + 1):
        if s[i: i + l] != s[i: i + l][::-1]:
            ans = l

stdout.write(str(ans))

s = input()
isp = 1
onl = 1
for i in range(len(s)):
    if (i>0 and s[i-1]!=s[i]):
        onl = 0
    if (s[i]!=s[len(s)-i-1]):
        isp = 0
if (not isp):
    print(len(s))
else:
    if (onl):
        print(0)
    else:
        print(len(s)-1)
    


            
        
    
    
    
    
        
    
    
    

    
    
   



s=input()
ans=0
n=len(s)
for i in range(n):
    for j in range(i+1,n+1):
        c=s[i:j]
        if c!=c[::-1] and j-i>ans:
            ans=j-i
print(ans)


s = input()

if s[::] != s[::-1]:
    print(len(s))

elif len(set(s)) == 1:
    print(0)

else:
    print(len(s) - 1)


def func(w):
    return w != w[::-1]

word = input().strip()

ss = [word[i:j] for i in range(len(word)) for j in range(i+1, len(word)+1) if func(word[i:j])]

print(max(len(w) for w in ss) if ss else 0)


def is_palindrome(ss):
    return ss == ss[::-1]

s = input().strip()
best = 0
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        if not is_palindrome(s[i:j]):
            best = max(best, j - i)
print(best)


#l=[(int(i))for i in input().split()]
s = input()
if(s.count(s[0]) == len(s)):
	print(0)
elif s == s[::-1]:
	print(len(s)-1)
else:print(len(s))	

ch=input()
while(ch==ch[::-1] and len(ch)>=1):
      ch=ch[:-1]
if(len(ch)==1):
      print(0)
else:
      print(len(ch))
      


import sys

input = sys.stdin.readline

s = input().strip()
maxlen = 0

def checkpalin(s):
    i = 0
    j = len(s) - 1
    while (i < j):
        if (s[i] != s[j]):
            return False
        i += 1
        j -= 1
    return True

for i in range(len(s)):
    for j in range(i, len(s)):
        if not checkpalin(s[i:j+1]):
            maxlen = max(maxlen, len(s[i:j+1]))

print(maxlen)

s = input()
ans = 0
def pal(p):
    return p == p[::-1]
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        if (not pal(s[i:j])):
            ans = max(ans, j - i)
print(ans)


s = input()
if (s!=s[::-1]):
    print(len(s))
else:
    if (len(set(s))==1):
        print(0)
    else:
         print(len(s)-1)


s = input()
n = len(s)
ans  = 0
for i in range(n):
    for j in range(i, n):
        a = s[i : j + 1]
        b = ""
        for item in a:
            b = item + b
        if (a != b):
            ans = max(ans, len(a))
print(ans)

s = input()
n = len(s)
best = 0
for l in range(n + 1):
    if s[0:l][::-1] != s[0:l]:
        # print(s[:l], s[: l][::-1])
        best = l

print(best)


s = input()
for i in range(len(s)):
    if (s[i] != s[-i - 1]):
        print(len(s))
        break
else:
    for i in s:
        if (i != s[0]):
            print(len(s) - 1)
            break
    else:
        print(0)

s = input()
ans = 0
for i in range(len(s), 0, -1):
    for j in range(i - 1, len(s)):
        if s[j - i + 1:j + 1] != s[j - i + 1:j + 1][::-1]:
            ans = max(ans, i)
print(ans)


ch=input()
#rofllll this is so easy mannn
while(ch==ch[::-1] and len(ch)>=1):
      ch=ch[:-1]
if(len(ch)==1):
      print(0)
else:
      print(len(ch))
      


s = input()
k = set(list(s))
if len(k) == 1: print(0)
elif s == s[::-1]: print(len(s)-1)
else: print(len(s))