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: EASY
Tags: String algorithms

Implementation

Complete search
Skill types: Complete search
Expected Time Complexity: O(N)

Starter code:

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


word = input()
while word == word[::-1]:
	if len(word) == 1:
		word = ''
		break
	word = word[0:-1]
print(len(word))


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


def isPalindrom(s):
	n2 = len(s)
	n = n2 // 2
	n2 -= 1
	for i in range(n):
		if s[i] != s[n2 - i]:
			return n2 + 1
	return 0
s = input()
n = len(s)
ans = 0
for i in range(n):
	for j in range(n - 1, i, -1):
		ans = max(ans, isPalindrom(s[i:j + 1]))
print(ans)


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


import math
s = input()
count = 0
for i in range(len(s)):
	for j in range(i + 1, len(s) + 1):
		x = s[i:j]
		if x[:math.ceil(len(x) / 2)] == x[::-1][:math.ceil(len(x) / 2)]:
			pass
		else:
			count = max(len(x), count)
print(count)


is_pal = lambda string: string == string[::-1]
word = input()
l = len(word)
longest_substr_len = 0
for i in range(l):
	for j in range(l - i):
		sub_str = word[j:l - i]
		sub_str_len = len(sub_str)
		if not is_pal(sub_str) and sub_str_len > longest_substr_len:
			longest_substr_len = sub_str_len
print(longest_substr_len)


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


def is_palindrom(s):
	ans = True
	for i in range(len(s)):
		if s[i] != s[-(i + 1)]:
			ans = False
			break
	return ans

def mine():
	s = input()
	left = 0
	right = 0
	len_c = 0
	while left < len(s):
		right = left + len_c + 1
		while right < len(s):
			if not is_palindrom(s[left:right + 1]):
				len_c = max(len_c, right - left + 1)
			right += 1
		left += 1
	print(len_c)
mine()


def isPalin(s):
	temp = [s[i] for i in range(len(s) - 1, -1, -1)]
	s = list(s)
	if s == temp:
		return True
	else:
		return False
s = input()
i = 0
n = len(s)
while i < n:
	if not isPalin(s[:n - i]):
		print(len(s[:n - i]))
		break
	i += 1
if n == i:
	print(0)


S = input()
c = int

def ispal(a):
	global c
	for i in range(len(a) // 2 + 1):
		if ord(a[i]) == ord(a[len(a) - i - 1]) or ord(a[i]) == ord(a[len(a) - i - 1]) + ord('A') - ord('a') or ord(a[i]) == ord(a[len(a) - i - 1]) - ord('A') + ord('a'):
			c = 1
		else:
			c = 0
			break
	return c
answer = int
if len(S) == 1:
	answer = 0
elif ispal(S) == 0:
	answer = len(S)
elif ispal(S[:-1]) == 0:
	answer = len(S) - 1
else:
	answer = 0
print(answer)


n = input()
count = 0
if len(set(n)) == 1:
	print('0')
elif n == n[::-1]:
	print(len(n) - 1)
else:
	print(len(n))


s = input()
ans = len(s)
while s[::-1] == s and ans > 0:
	s = s[1:]
	ans -= 1
	if s == s[::-1]:
		s = s[:-1]
		ans -= 1
	else:
		break
ans = 0 if ans < 0 else ans
print(ans)


a = input().upper()
b = [a[i] for i in range(0, len(a), 1)]
inverso = ''
for n in range(len(a) - 1, -1, -1):
	inverso += a[n]
c = [inverso[i] for i in range(0, len(inverso), 1)]
while a == inverso and len(a) > 0:
	b.pop(-1)
	c.pop(0)
	a = ''.join(b)
	inverso = ''.join(c)
print(len(a))


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


s = input()
l = len(s)
s2 = s[::-1]
if s == s2:
	if s == s[0] * l:
		print(0)
	else:
		print(l - 1)
else:
	print(l)


def check(i, j, S):
	if i >= j:
		return 1
	if S[i] == S[j]:
		return check(i + 1, j - 1, S)
	return 0
S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
		if not check(i, j, S):
			ans = max(ans, j - i + 1)
print(ans)


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


def is_pal(w):
	return w == w[::-1]
word = input()
out = ''
for i in range(len(word), -1, -1):
	temp = word[:i]
	if not is_pal(temp):
		out = temp
		break
print(len(out))


a = input()
n = len(a)
for length in range(n, 0, -1):
	f = 0
	for i in range(n - length + 1):
		if a[i:i + length] != a[i:i + length][::-1]:
			print(length)
			f = 1
			break
	if f:
		break
else:
	print(0)


S = list(input())
L = len(S)
if S.count(S[0]) == L:
	print(0)
elif S == S[::-1]:
	print(L - 1)
else:
	print(L)


s = input()
if s != s[::-1]:
	print(len(s))
else:
	z = True
	for a in s:
		if a != s[0]:
			z = False
	if z:
		print(0)
	else:
		print(len(s) - 1)


def palindrome(s):
	ans = True
	for i in range(len(s)):
		if s[i] != s[len(s) - i - 1]:
			ans = False
	return ans
s = input()
n = len(s)
ans = 0
for l in range(n):
	for r in range(l, n):
		if not palindrome(s[l:r + 1]):
			ans = max(ans, len(s[l:r + 1]))
print(ans)


def isPalindrome(s):
	return s == s[::-1]
s = input()
n = len(s)
if len(set(s)) == 1:
	print(0)
elif isPalindrome(s):
	print(n - 1)
else:
	print(n)


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


def main():
	letra = input()
	tamano = len(letra)
	a = letra[0]
	b = letra[0]
	i = 0
	contador = 0
	while a == b and i < tamano:
		b = letra[i]
		if a == b:
			contador += 1
		i += 1
	if contador == tamano:
		print(0)
	elif tamano % 2 == 0:
		palabra1 = ''
		palabra2 = ''
		for i in range(int(tamano / 2)):
			palabra1 += letra[i]
		for j in range(tamano - 1, int(tamano / 2) - 1, -1):
			palabra2 += letra[j]
		if palabra1 == palabra2:
			print(tamano - 1)
		else:
			print(tamano)
	else:
		palabra1 = ''
		palabra2 = ''
		for i in range(int(tamano / 2)):
			palabra1 += letra[i]
		for j in range(tamano - 1, int(tamano / 2), -1):
			palabra2 += letra[j]
		if palabra1 == palabra2:
			print(tamano - 1)
		else:
			print(tamano)
main()


def reverse_string(s):
	return s[::-1]
s = input()
while len(s) > 0 and s[:len(s) // 2] == reverse_string(s[len(s) // 2 + len(s) % 2:]):
	s = s[:-1]
print(len(s))


from copy import deepcopy
import itertools

def read():
	return int(input())

def readmap():
	return map(int, input().split())

def readlist():
	return list(map(int, input().split()))

def is_palindrome(string):
	return True if string == string[::-1] else False
S = input()
if S.count(S[0]) == len(S):
	print(0)
else:
	for l in reversed(range(1, len(S) + 1)):
		for i in range(len(S) - l + 1):
			if not is_palindrome(S[i:i + l]):
				print(l)
				quit()


s = input()
f = 0
for i in s:
	if i == s[0]:
		f += 1
if f == len(s):
	print('0')
elif s == s[::-1]:
	print(len(s) - 1)
else:
	print(len(s))


s = input()
cnt = 1
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		cnt += 1
if s != s[::-1]:
	print(len(s))
elif len(s) == cnt:
	print('0')
elif s == s[::-1]:
	print(len(s) - 1)


s = str(input())
n = len(s)
i = n - 1
flag = 0
ans = 0
while i > 0:
	z = 0
	j = i
	while j < n:
		k = z
		l = j
		while l > k:
			if s[l] != s[k]:
				flag = 1
				ans = i + 1
				break
			k += 1
			l -= 1
		if flag == 1:
			break
		j += 1
		z += 1
	if flag == 1:
		break
	i -= 1
print(ans)


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


s = input()
l = list(s)
lr = l[::-1]
if l != lr:
	print(len(s))
elif len(set(l)) == 1:
	print('0')
else:
	print(len(s) - 1)


n = input()
s = {x for x in n}
r = n[::-1]
print(0) if len(s) == 1 else print(len(n) - 1) if r == n else print(len(n))


def isPal(string):
	return string[::-1] == string

def main():
	string = input()
	result = 0
	for i in range(len(string) + 1):
		for j in range(i + 1, len(string) + 1):
			if not isPal(string[i:j]):
				result = max(result, len(string[i:j]))
	print(result)
main()


s = input()
if s != s[::-1]:
	print(len(s))
elif s == s[::-1] and s.count(s[0]) != len(s):
	print(len(s) - 1)
else:
	print(0)


s = input()
p = s[len(s) // 2:len(s)]
if s == s[0] * len(s):
	print(0)
elif len(s) % 2 == 0 and s[0:len(s) // 2] == p[::-1]:
	print(len(s) - 1)
elif len(s) % 2 == 1 and s[0:len(s) // 2 + 1] == p[::-1]:
	print(len(s) - 1)
else:
	print(len(s))


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


def ispalindrome(s):
	l = len(s) // 2
	t = True
	for i in range(l):
		if s[i] != s[len(s) - 1 - i]:
			t = False
	return t
s = input()
x = len(s)
ans = 0
t = True
for i in range(0, len(s)):
	for j in range(i + 1):
		t = ispalindrome(s[j:j + x])
		if not t:
			ans = x
			break
	if not t:
		break
	x -= 1
print(ans)


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)


n = input()
while len(n) > 0:
	if n != n[::-1]:
		break
	else:
		n = n[:len(n) - 1]
print(len(n))


def reverse(string):
	string1 = string[::-1]
	return string1
n = 0
string = input()
s1 = reverse(string)
if s1 == string:
	y = len(string)
	for i in range(0, y):
		for j in range(0, y):
			if string[i] == s1[j]:
				n = n + 1
	y = len(string)
	z = y * y
	if n == z:
		print('0')
	else:
		y = len(string) - 1
		print(y)
else:
	print(len(string))


def ispad(str):
	if str == str[::-1]:
		return 1
	else:
		return 0
a = input()
max = 0
i = 0
while i < len(a):
	j = i
	while j < len(a) + 1:
		if ispad(a[i:j]) == 0 and len(a[i:j]) > max:
			max = len(a[i:j])
		j += 1
	i += 1
print(max)


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()
count = 0
l = len(s)
for i in range(l - 1, 0, -1):
	k = s[::-1]
	if k != s or k == '':
		break
	else:
		s = s.replace(s[i], '', 1)
		count = count + 1
if len(s) == 1:
	print(0)
else:
	g = l - count
	print(g)


a = input()
b = len(a)
c = a[::-1]
if a != c:
	print(b)
elif a.count(a[0]) == b:
	print('0')
else:
	print(b - 1)


def egal(s):
	v = {*s}
	if len(v) == 1:
		return 1
	return 0

def pal(s):
	ok = 0
	for i in range(0, len(s) // 2):
		if s[i] != s[len(s) - i - 1]:
			ok = 1
			return 0
	if ok == 0:
		return 1

def lung(s):
	if pal(s) == 1 and egal(s) == 1:
		print(0)
	elif pal(s) == 1:
		print(len(s) - 1)
	else:
		print(len(s))
s = input()
lung(s)


a = input()
new = a
n = len(a)
flag = 0
pp = 0
for i in range(0, len(a) // 2):
	if a[i] != a[len(a) - i - 1]:
		flag = 1
		break
string = a.replace(a[n - 1], '', 1)
for j in range(0, len(string) // 2):
	if string[j] != string[len(string) - j - 1]:
		pp = 2
		break
if flag == 1:
	print(len(a))
elif pp == 2:
	print(len(string))
elif flag != 1:
	print(0)


word = input()
substrings = []
for i in range(len(word)):
	for j in range(i, len(word)):
		substrings.append(word[i:j + 1])
maxLen = 0
for sub in substrings:
	if sub != sub[::-1]:
		if len(sub) > maxLen:
			maxLen = len(sub)
print(maxLen)


a = input()
s = ''
n = 0
s += a[::-1]
if s != a:
	print(len(a))
elif s == a:
	n = len(a)
	x = s
	while x == x[::-1] and n > 0:
		n -= 1
		s = s[:n]
		x = s
	print(n)


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


def palindrom(str):
	return str == str[::-1]
str = str(input())
flag = True
for i in range(len(str), 0, -1):
	for j in range(len(str) - i + 1):
		if not palindrom(str[j:j + i]):
			flag = False
			print(i)
			break
	if not flag:
		break
if flag:
	print(0)


s = input()
n = len(s)
arr = []

def palindrome(s):
	k = n
	for i in range(k // 2):
		if s[i] != s[k - i - 1]:
			return True
	return False
boolean = True
t = n
f = n
e = 1
if palindrome(s) == boolean:
	print(n)
else:
	for i in range(n - 1, 1, -1):
		if s[i] == s[i - 1]:
			e = 1
		else:
			e = 7
			break
	if e == 1:
		print(0)
	else:
		print(n - 1)


def antipalindrome(A):
	front = 0
	end = len(A) - 1
	duplicates = 1
	temp = A[front]
	while front <= end:
		if temp != A[front]:
			duplicates = 0
		if A[front] != A[end]:
			return len(A)
		temp = A[front]
		front = front + 1
		end = end - 1
	if duplicates:
		return 0
	else:
		return len(A) - 1
A = list(input())
print(antipalindrome(A))


def func(s):
	while len(s):
		s2 = s[::-1]
		if s != s2:
			print(len(s))
			return
		else:
			s = s[1:]
	print(0)
s = input()
func(s)


n = input()
a = ''
b = len(n)
j = 1
for i in range(1, b):
	if n[0] == n[i]:
		j = j + 1
if j == b:
	print(0)
else:
	for i in range(b - 1, -1, -1):
		a = a + n[i]
	if a == n:
		print(b - 1)
	else:
		print(b)


s = input()
pal = True
eqs = True
c0 = s[0]
for i in range(len(s)):
	if s[i] != c0:
		eqs = False
	if s[i] != s[-i - 1]:
		pal = False
if eqs:
	print(0)
elif pal:
	print(len(s) - 1)
else:
	print(len(s))


s = list(input())
sl = list(set(s))
if len(sl) == 1:
	print(0)
else:
	i = 0
	j = len(s) - 1
	while s[i] == s[j]:
		i += 1
		j -= 1
		if i >= j:
			break
	if i >= j:
		print(len(s) - 1)
	else:
		print(len(s))


s = input()
c = c1 = 0
for i in range(len(s) // 2):
	if s[i] == s[len(s) - i - 1]:
		c += 1
for i in range(len(s)):
	if s[i] == s[0]:
		c1 += 1
if c1 == len(s):
	print(0)
elif c == len(s) // 2:
	print(len(s) - 1)
else:
	print(len(s))


s = input()
for l in range(len(s), 0, -1):
	for i in range(0, len(s) - l + 1):
		cur = s[i:i + l]
		if cur != cur[::-1]:
			print(l)
			exit()
print(0)


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

def substr(s):
	for i in range(len(s), 0, -1):
		for j in range(len(s) - i + 1):
			yield s[j:j + i]

def longest_palindromic(a):
	for elem in substr(a):
		if not is_palindrome(elem):
			return len(elem)
	return 0
s = input()
print(longest_palindromic(s))


def check(string):
	L = 0
	R = len(string) - 1
	while L <= R:
		if string[L] == string[R]:
			L += 1
			R -= 1
		else:
			return False
	return True

def check_equal(string):
	dic = {}
	for i in range(len(string)):
		if string[i] not in dic:
			dic[string[i]] = 1
			if len(dic) == 2:
				return False
	return True

def antipalindrome():
	word = input()
	if not check(word):
		return len(word)
	else:
		if check_equal(word):
			return 0
		i = 1
		maximum = 0
		while True:
			temp = word[i:]
			if not check(temp):
				length = len(temp)
				if length > maximum:
					maximum = length
			i += 1
			if i == len(word):
				break
		i = 1
		while True:
			temp = word[:i]
			if not check(temp):
				length = len(temp)
				if length > maximum:
					maximum = length
			i += 1
			if i == len(word):
				break
		return maximum
A = antipalindrome()
print(A)


def checkString(str):
	first = str[0]
	for i in range(len(str)):
		if str[i] != first:
			return False
	return True

def isPalindrom(str):
	return str == str[::-1]
word = input()
if checkString(word):
	print(0)
elif isPalindrom(word):
	print(len(word) - 1)
else:
	print(len(word))


s = input()
ans = 0
skip = False
if len(s) == 1:
	skip = True
else:
	while s[:] == s[::-1]:
		s = s[:len(s) - 1]
		if len(s) == 1:
			ans = 0
			skip = True
			break
if skip == False:
	ans = len(s)
print(ans)


s = input()
print((len(s) - (s == s[::-1])) * (len(set(s)) > 1))


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


s = input()
n = len(s)
ret = 0
for (i, a) in enumerate(s):
	for j in range(i + 1, n):
		b = s[j]
		if a != b:
			v = j - i + 1 + 2 * min(n - 1 - j, i)
			ret = max(ret, v)
print(ret)


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


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

def equals(s):
	for i in range(len(s)):
		if s[i] != s[0]:
			return False
	return True
s = input()
if equals(s):
	print(0)
elif not check_pali(s, 0, len(s) - 1):
	print(len(s))
else:
	print(len(s) - 1)


def palim(a):
	return a == a[::-1]
a = input()
found = False
ex = 0
for i in range(len(a), 0, -1):
	for j in range(len(a) - i):
		if not palim(a[0 + j:0 + i + j + 1]):
			found = True
			ex = len(a[0 + j:0 + i + j + 1])
			break
	if found:
		break
print(ex)


def kaibun(s):
	for i in range(len(s)):
		if s[i] != s[-1 - i]:
			return False
	return True
s = input()
l = len(s)
m = 0
for i in range(l):
	for j in range(i + 1, l + 1):
		if not kaibun(s[i:j]):
			m = max(m, j - i)
print(m)


n = input()
flag = True
for i in range(int(len(n) / 2)):
	if n[i] != n[len(n) - i - 1]:
		flag = False
		break
if flag == True:
	while flag == True:
		n = n[:len(n) - 1]
		for i in range(int(len(n) / 2)):
			if n[i] != n[len(n) - i - 1]:
				flag = False
				break
		if n == '':
			break
	print(len(n))
else:
	print(len(n))


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)


a = input()
b = []
c = []
for i in a:
	b.append(i)
	c.append(i)
c.reverse()
d = set(b)
if c != b:
	print(len(c))
elif len(d) == 1:
	print(0)
else:
	print(len(c) - 1)


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


s = input()
n = len(s)
flag = 0
for i in reversed(range(n)):
	for j in range(n):
		if j + i + 1 <= n:
			p = s[j:j + i + 1]
			if p != p[::-1]:
				flag = i + 1
				break
		else:
			break
	if flag > 0:
		break
print(flag)


def pal(s):
	return s == s[::-1]
s = input()
f = s.count(s[0])
if f == len(s):
	print(0)
elif pal(s):
	print(len(s) - 1)
else:
	print(len(s))


s = input()
l = set()
for c in s:
	l.add(c)
if len(l) == 1:
	print(0)
elif s == s[::-1]:
	print(len(s) - 1)
else:
	print(len(s))


a = str(input())
q = a[-1::-1]
while len(q) > 0:
	if q == q[-1::-1]:
		q = q[-2::-1][-1::-1]
	else:
		break
print(len(q))


word = input()

def palindrom(word1, word2):
	if len(word1) != len(word2):
		word2 += word1[-(len(word2) + 1)]
	elif word1 == word2:
		return True
	else:
		return False
	return palindrom(word1, word2)
i = 1
while palindrom(word, '') and len(word) > 0:
	word = word[i:]
	i += 1
print(len(word))


def isPalindromo(word):
	middle = len(word) // 2
	n = len(word) - 1
	for index in range(middle):
		if word[index] != word[n - index]:
			return False
	return True
word = input()
if len(set(word)) == 1:
	print(0)
elif isPalindromo(word):
	print(len(word) - 1)
else:
	print(len(word))


a = input()
b = len(a)
if b % 2 == 0:
	x = b // 2
else:
	x = b // 2 + 1
c = 0
d = 0
for i in range(0, x):
	if a[i] != a[b - i - 1]:
		print(b)
		c = 0
		break
	else:
		c = 1
if c == 1:
	for i in range(0, x - 1):
		if a[0] != a[i + 1]:
			d = 1
			break
		else:
			d == 0
	if d == 0:
		print(0)
	else:
		print(b - 1)


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


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


def antipalindrome(s):
	count = 0
	temp = s[:]
	while temp == temp[::-1]:
		if len(temp) != 1:
			temp.pop()
		else:
			print(0)
			return
	print(len(temp))
antipalindrome(list(input()))


str = input()
if all((item == str[0] for item in str)):
	exit(print(0))
if str[::-1] == str:
	print(len(str) - 1)
else:
	print(len(str))


a = input()
print((len(a) - (a == a[::-1])) * (len(set(a)) != 1))


s = input()
l = len(s)
k = j = i = 0
while len(s) > k + 1 and s[k] == s[k + 1]:
	k += 1
if k + 1 == len(s):
	print('0')
elif l % 2 == 0:
	while i < l // 2:
		if s[0 + i] == s[-i - 1]:
			j += 1
		i += 1
	if j == l // 2:
		print(l - 1)
	else:
		print(l)
else:
	while i < l // 2:
		if s[0 + i] == s[-i - 1]:
			j += 1
		i += 1
	if j == l // 2:
		print(l - 1)
	else:
		print(l)


def isPalindrome(str):
	n = len(str)
	for i in range(n // 2):
		if str[i] != str[n - i - 1]:
			return False
	return True

def maxLengthNonPalinSubstring(str):
	n = len(str)
	ch = str[0]
	i = 1
	for i in range(1, n):
		if str[i] != ch:
			break
	if i == n:
		return 0
	if isPalindrome(str):
		return n - 1
	return n
str1 = input()
n = len(str1)
if str1.count(str1[0]) == n:
	print(0)
else:
	print(maxLengthNonPalinSubstring(str1))


def palin(stri):
	for i in range(len(stri) // 2):
		if stri[i] != stri[-i - 1]:
			return len(stri)
	if len(stri) == 1:
		return 0
	return palin(stri[:-1])
s = input()
print(palin(s))


def ispalin(s):
	for i in range(len(s) // 2):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True
z = input()
a = []
for i in range(len(z)):
	a.append(z[i])
c = len(a)
d = c
for i in range(len(a)):
	b = ispalin(a)
	if b == True:
		d = d - 1
		del a[len(a) - 1]
	else:
		d = len(a)
print(d)


def check_if_polyndrome(string):
	return string == string[::-1]
string = input()
while check_if_polyndrome(string) and len(string) >= 1:
	string = string[:-1]
print(len(string))


def is_antipalindrome(subword):
	for i in range(int(len(subword) / 2)):
		if str(subword[i]) != str(subword[-(i + 1)]):
			return True
	return False

def max_antipalindrome(subword):
	if is_antipalindrome(subword):
		return len(subword)
	elif is_antipalindrome(subword[1:]) or is_antipalindrome(subword[:-1]):
		return len(subword) - 1
	else:
		return 0
word = input()
print(str(max_antipalindrome(word)))


import sys

def main():
	a = list(input())
	m = False
	i = 0
	j = len(a) - 1
	while i < j + 1:
		if a[i] != a[j]:
			print(len(a))
			sys.exit()
		elif a[0] != a[i]:
			m = True
		i += 1
		j -= 1
	if m:
		print(len(a) - 1)
	else:
		print(0)
main()


s = input()
a = []
for i in s:
	a.append(i)
b = a[::-1]
temp = True
if a == b:
	for i in range(len(a)):
		if len(a) != 0:
			del a[-1]
			b = a[::-1]
			if a == b:
				temp == True
			else:
				temp == False
				break
print(len(a))


s = input()
x = list(s)
y = []
f = 0
for j in range(0, len(s)):
	if x[j - 1] != x[j]:
		f = 1
		break
if f == 0:
	print(0)
else:
	for i in range(1, len(s) + 1):
		y.append(x[-i])
	if x == y:
		print(len(s) - 1)
	elif x != y:
		print(len(s))


s = input().strip()
n = len(s)
c = s.count(s[0])
if s != s[::-1]:
	print(n)
elif n == c:
	print(0)
else:
	print(n - 1)


def ok(s):
	return s == s[::-1]
s = str(input())
for i in range(len(s)):
	if ok(s[i:]) == False:
		print(len(s[i:]))
		exit()
print(0)


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


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


def anti(word):
	temp = word[::-1]
	if temp != word:
		return len(word)
	k = word[0]
	num = 0
	for i in word:
		if k == i:
			num += 1
		else:
			break
	if num == len(word):
		return 0
	return len(word) - 1
word = input()
print(anti(word))


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


s = input()
ans = 0
flag = 0
for t in range(1, len(s)):
	for i in range(t):
		p = s[i:t + 1]
		if len(p) % 2 == 0:
			if p[0:len(p) // 2] != p[len(p) // 2:][::-1]:
				ans = max(t - i + 1, ans)
		elif p[0:len(p) // 2] != p[len(p) // 2 + 1:][::-1]:
			ans = max(len(p), ans)
print(ans)


st = input()

def pal(s):
	p = ''
	l = len(s)
	for i in range(l - 1, -1, -1):
		p = p + s[i]
	if s == p:
		return True
	else:
		return False
pa = st
for i in range(len(st)):
	if pal(pa):
		pa = pa.replace(pa[i], '1', 1)
		pa = pa + '1'
	else:
		pa = pa.replace('1', '')
		z = len(pa)
		print(z)
		break
if 2 * len(st) == len(pa):
	print(0)


def subs(string):
	length = len(string)
	alist = []
	for i in range(length):
		for j in range(i, length):
			alist.append(string[i:j + 1])
	return alist
lista = subs(input())
lista.sort(key=len)
lista = lista[::-1]
flag = 0
for x in lista:
	if x != x[::-1]:
		print(len(x))
		flag = 1
		break
if flag == 0:
	print('0')


name = input()

def isPali(name):
	if name == name[::-1]:
		return True
	else:
		return False
limit = len(name)
tries = 0
while isPali(name) and tries < limit:
	name = name[:-1]
	tries += 1
print(len(name))


s = input()
if s != s[::-1]:
	print(len(s))
else:
	res = []
	for i in range(1, len(s) + 1):
		string = s[i:]
		if string != string[::-1]:
			res.append(len(string))
	if len(res) == 0:
		print('0')
	else:
		print(res[0])


s = input()

def find(s):
	for i in range(len(s) // 2):
		if s[i] != s[len(s) - i - 1]:
			return len(s)
	return -1
for i in range(len(s)):
	k = find(s[i:])
	if k != -1:
		print(k)
		break
else:
	print(0)


string = [i for i in input()]
if string.count(string[0]) == len(string):
	print(0)
elif len(string) % 2 == 0:
	half = len(string) // 2
	if string[:half] == string[half:][::-1]:
		print(len(string) - 1)
	else:
		print(len(string))
else:
	half = len(string) // 2 + 1
	if string[:half - 1] == string[half:][::-1]:
		print(len(string) - 1)
	else:
		print(len(string))


def palindrom(s):
	for i in range(len(s)):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True
s = input()
if not palindrom(s):
	print(len(s))
elif not palindrom(s[1:]):
	print(len(s) - 1)
elif not palindrom(s[:-1]):
	print(len(s) - 1)
else:
	print(0)


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)


import sys
input = sys.stdin.readline
S = input().strip()

def isPal(s):
	return s == s[::-1]

def main():
	if not isPal(S):
		return len(S)
	else:
		PAL = []
		for i in range(len(S) + 1):
			for j in range(i + 1, len(S) + 1):
				s = S[i:j]
				if not isPal(s):
					PAL.append(len(s))
		if PAL:
			return max(PAL)
	return 0
print(main())


string = input()
while string == string[::-1] and string:
	string = string[1:]
print(len(string))


str = input()

def is_pa(str):
	if len(str) % 2 == 1:
		rev = ''
		for i in range(int(len(str) / 2)):
			rev += str[-(i + 1)]
		if str[:int(len(str) / 2)] == rev:
			return True
		return False
	else:
		rev = ''
		for i in range(int(len(str) / 2)):
			rev += str[-(i + 1)]
		if str[:int(len(str) / 2)] == rev:
			return True
		return False
count = len(str)
while count > 0:
	yes = False
	for i in range(len(str) - count + 1):
		s = ''
		for ii in range(count):
			s += str[i + ii]
		if is_pa(s) == False:
			yes = True
	if yes == True:
		break
	else:
		count -= 1
print(count)


def palin(s):
	for i in range(len(s) // 2):
		if s[i] == s[len(s) - 1 - i]:
			continue
		else:
			return True
	return False
s = input()
if palin(s):
	print(len(s))
	exit()
maxi = 0
for i in range(len(s)):
	for j in range(len(s)):
		if palin(s[i:j + 1]):
			if maxi < len(s[i:j + 1]):
				maxi = len(s[i:j + 1])
print(maxi)


def isp(st):
	if len(st) != 1:
		if st == st[::-1]:
			return 1
	return 0
s = input()
k = 0
for c in range(len(s)):
	if (not isp(s[:len(s) - c]) or not isp(s[len(s) - c::-1])) and c != len(s) - 1:
		k = len(s[:len(s) - c])
		break
print(k)


a = input()
b = a[::-1]
li = list(b)
if a != b:
	print(len(a))
elif a == b:
	p = list(a)
	for i in range(len(p)):
		p.pop()
		if p != p[::-1]:
			print(len(p))
			break
	else:
		print('0')


s = input()
n = len(s)
Ans = 0
for i in range(n):
	for j in range(i + 1, n):
		L = i
		R = j
		while L < R and s[L] == s[R]:
			L += 1
			R -= 1
		if L < R and Ans < j - i + 1:
			Ans = j - i + 1
print(Ans)


s = list(input())
n = len(s)
while n and s == s[::-1]:
	s.pop()
	n -= 1
print(n)


s = input()

def is_palindrome(s):
	if len(s) == 0:
		return True
	if len(s) == 1:
		return True
	if s[0] == s[-1]:
		return is_palindrome(s[1:len(s) - 1])
	return False

def func(s):
	if is_palindrome(s):
		return max(func(s[:len(s) - 1]), func(s[1:]))
	return len(s)
if len(set(s)) == 1:
	print(0)
else:
	print(func(s))


def pal(r):
	if r == r[::-1]:
		return True
	else:
		return False
s = str(input())
if pal(s) == True:
	if pal(s[0:len(s) - 1]) == True:
		print(0)
	else:
		print(len(s) - 1)
else:
	print(len(s))


word = input()
if word != word[::-1]:
	print(len(word))
else:
	max_len = 0
	for i in range(1, len(word)):
		if word[i:] != word[i:][::-1] and len(word) - i > max_len:
			max_len = len(word) - i
		if word[:len(word) - i] != word[:len(word) - i][::-1] and len(word) - i > max_len:
			max_len = len(word) - i
	print(max_len)


def isPalindrome(s):
	reverse = s[::-1]
	if s == reverse:
		return True
	else:
		return False

def sameChars(s):
	l = len(s)
	for i in range(0, l - 1):
		if s[i] != s[i + 1]:
			return False
	return True

def solution(s):
	if isPalindrome(s):
		if sameChars(s):
			return 0
		else:
			return len(s) - 1
	else:
		return len(s)
s = input()
ans = solution(s)
print(ans)


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


r = input()
x = len(r)
e = 0
for i in range(x):
	for j in range(x):
		r1 = r[i:j + 1]
		if r1 != r1[::-1]:
			re = len(r1)
			if re > e:
				e = re
print(e)


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


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


n = input()
if len(n) == 1:
	print(0)
elif n[::-1] != n:
	print(len(n))
else:
	while True:
		n = n[:-1]
		s = n[::-1]
		if s != n:
			print(len(s))
			break
		elif len(s) == 1:
			print(0)
			break


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


def is_palindrome(s):
	return s == s[::-1]
s = input().strip()
while is_palindrome(s) and len(s) > 0:
	s = s[:-1]
print(len(s))


s = input()
if s == s[::-1]:
	if s.count(s[0]) == len(s):
		print(0)
	else:
		print(len(s) - 1)
else:
	print(len(s))


n = input()
cnt = 0
l = len(n)
while l >= 0:
	for i in range(0, l):
		if n[i] != n[l - 1 - i]:
			cnt += 1
	if cnt >= 1:
		print(l)
		l = -1
	else:
		l = l - 1
	if l == 0:
		print(0)


def largest_no_pal(s):
	if not s or s != s[::-1] or (len(set(s)) == len(s) and len(s) != 1):
		return len(s)
	temp_arr = []
	for i in range(len(s)):
		for j in range(len(s) - 1, i, -1):
			temp = s[i:j + 1]
			if temp != temp[::-1]:
				temp_arr.append(temp)
	if not temp_arr:
		return 0
	return len(max(temp_arr, key=lambda x: len(x)))
inp = input()
print(largest_no_pal(inp))


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


def ispal(n):
	ans = ''
	for i in range(len(n) - 1, -1, -1):
		ans += n[i]
	if ans == n:
		return True
	return False
s = input()
ans = len(s)
f = 1
for i in range(len(s)):
	if ispal(s):
		s = s[:-1]
		ans -= 1
	else:
		print(ans)
		f = 0
		break
if f == 1:
	print(0)


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


def is_palindrome(word):
	palindrome = True
	size = len(word)
	middle = int(size / 2)
	for i in range(0, middle):
		palindrome = palindrome and word[i] == word[size - i - 1]
	return palindrome
word = str(input())
size = len(word)
i = 0
while is_palindrome(word[i:]) and i < size:
	i += 1
size -= i
print(size)


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


def palindrom(kata, n):
	for i in range(int(n)):
		if kata[i] != kata[n - i - 1]:
			return 0
	return 1
kata = input()
cek = 1
n = len(kata)
while cek == 1 and n > 0:
	cek = palindrom(kata, n)
	if cek == 1:
		n -= 1
print(n)


def reverse(str):
	new_str = ''
	for i in range(len(str) - 1, -1, -1):
		new_str += str[i]
	return new_str

def is_palindrome(str):
	return str == reverse(str)
s = input()
if is_palindrome(s):
	if is_palindrome(s[:len(s) - 1]):
		print(0)
	else:
		print(len(s) - 1)
else:
	print(len(s))


def pali(string):
	res = True
	for i in range(len(string) // 2):
		if string[i] != string[-(i + 1)]:
			res = False
			break
	return res

def main():
	string = input().strip()
	if pali(string):
		if all((x == string[0] for x in string)):
			print(0)
		else:
			print(len(string) - 1)
	else:
		print(len(string))
main()


s = input()
n = len(s)
k = 0
k1 = 0
c = s[n // 2]
for i in range(n // 2):
	if s[i] == s[n - i - 1]:
		k += 1
		if c == s[i]:
			k1 += 1
if k1 == n // 2:
	print(0)
elif k == n // 2:
	print(n - 1)
else:
	print(n)


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


string = str(input())
array = []
array2 = []
num = 0
max = 0
for i in range(len(string)):
	while 1 == 1:
		array.append(string[i + num])
		array2.append(string[i + num])
		num += 1
		if array != array2[::-1]:
			if len(array) > max:
				max = len(array)
		if len(string) <= i + num:
			break
	array = []
	array2 = []
	num = 0
print(max)


s = input()
l = len(s)
a = list(s)
b = []
cnt = 0
for i in range(l - 1, -1, -1):
	b.append(s[i])
while l > 0:
	b = a[::-1]
	if a != b:
		print(l)
		cnt = 1
		break
	else:
		a.pop(l - 1)
		l = l - 1
if cnt == 0:
	print(cnt)


def f(s):
	for i in range(len(s) // 2):
		if s[i] != s[-i - 1]:
			return False
	return True
s = input()
for l in range(len(s), -1, -1):
	for i in range(len(s) - l + 1):
		if not f(s[i:l + i]):
			print(l)
			raise SystemExit
print(0)


def isPalindrom(s):
	return s == s[::-1]
s = input()
max = 0
for i in range(len(s) - 1):
	for j in range(i + 1, len(s) + 1):
		if isPalindrom(s[i:j]) == False:
			if len(s[i:j]) > max:
				max = len(s[i:j])
print(max)


s = list(input())
s1 = s.copy()
s1.reverse()
if len(set(s)) == 1:
	print(0)
elif s1 == s:
	print(len(s) - 1)
else:
	print(len(s))


s = input()
if len(s) > 0 and len(s) <= 50 and s.islower():
	for i in range(len(s)):
		if s != ''.join(reversed(s)):
			print(len(s))
			exit()
		else:
			a = list(s)
			del a[0]
			s = ''.join(a)
	print(0)


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


import sys
import math
import bisect
import itertools
import random

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


s = str(input())
a = len(s)

def is_palindrome(s):
	for i in range(a // 2):
		if s[i] != s[a - i - 1]:
			return False
	return True
if is_palindrome(s) and len(set(s)) != 1:
	print(a - 1)
elif len(set(s)) == 1:
	print('0')
else:
	print(a)


s = list(input())
for i in range(len(s), 0, -1):
	for j in range(len(s) - i + 1):
		ss = s[j:i + 1]
		ssl = len(ss)
		for k in range(ssl // 2):
			if ss[k] != ss[ssl - k - 1]:
				print(ssl)
				exit(0)
print(0)


from __future__ import print_function
import sys, math, os.path

def eprint(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)
eprint('sdfdsf')
FILE_INPUT = 'A.in'
DEBUG = os.path.isfile(FILE_INPUT)
if DEBUG:
	sys.stdin = open(FILE_INPUT)

def ni():
	return map(int, input().split(' '))

def nia():
	return list(map(int, input().split()))

def log(x):
	if DEBUG:
		print(x)
s = input()

def test(s, ls, length):
	if length < 2:
		return 0
	for i in range(ls - length + 1):
		ss = s[i:i + length]
		if ss != ss[::-1]:
			return True
	return False

def find(s):
	ls = len(s)
	for leng in range(ls, 1, -1):
		if test(s, ls, leng):
			return leng
	return 0
print(find(s))


list1 = list(input())
lst = [0]
for i in range(len(list1) - 1):
	for j in range(i + 1, len(list1)):
		str1 = list1[i:j + 1]
		str2 = str1[::-1]
		if str1 != str2:
			lst.append(len(str1))
print(max(lst))


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)


def ehpalin(pal):
	if pal == pal[::-1]:
		return True
	return False
palavra = input()
a = 0
b = len(palavra)
while a != b and ehpalin(palavra[a:b]):
	a += 1
print(b - a)


a = list(input())
x = 0

def pal(a):
	b = list()
	for i in range(len(a) - 1, -1, -1):
		b.append(a[i])
	if a == b:
		return True
for i in range(len(a)):
	if pal(a) == True:
		a.pop(0)
	else:
		x += 1
print(x)


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


s = input()

def is_pal(s):
	r = ''.join(reversed(s))
	if s == r:
		return True
	return False

def sovle(s):
	n = len(s)
	if is_pal(s) == False:
		return n
	for i in range(0, n):
		s = s[1:]
		if is_pal(s) == False:
			return len(s)
		if len(s) == 0:
			return 0
print(sovle(s))


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


s = input()
d = 0
n = len(s)
for i in range(1, n):
	if s[i] == s[0]:
		d = d + 1
if d == n - 1:
	print('0')
	exit(0)
if d != n - 1:
	if s == s[::-1]:
		print(n - 1)
	else:
		print(n)


def isPal(S):
	for s in range(len(S)):
		if S[s] != S[len(S) - s - 1]:
			return False
	return True

def func(S, N):
	if not isPal(S):
		return N
	for i in range(N - 1):
		for j in range(i):
			if not isPal(S[j:N - i + j]):
				return N - i
	return 0
S = input()
N = len(S)
print(func(S, N))


def antipalindrome(str1):
	if str1 != str1[::-1]:
		return len(str1)
	elif len(set(str1)) == 1:
		return 0
	elif str1 == str1[::-1]:
		return len(str1) - 1
str1 = input()
print(antipalindrome(str1))


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


s = input()
n = len(s)

def IsPalindrome(n, t):
	i = 0
	stillIs = True
	while i < n // 2 and stillIs:
		if t[i] != t[n - i - 1]:
			stillIs = False
		i += 1
	return stillIs

def IsSingleLetter(n, t):
	for i in range(1, n):
		if t[i] != t[0]:
			return False
	return True
if not IsPalindrome(n, s):
	print(n)
elif IsSingleLetter(n, s):
	print(0)
else:
	print(n - 1)


word = input()
n = len(word)
first_letter = word[0]
if all((ch == first_letter for ch in word)):
	print(0)
elif word == word[::-1]:
	print(n - 1)
else:
	print(n)


def is_palindrome(word):
	return word == word[::-1]
word = input()
sem_palindromo = True
for i in range(len(word)):
	temp = word[i:]
	temp2 = word[:len(word) - i]
	temp3 = word[i:len(word) - i]
	if not is_palindrome(temp):
		print(len(temp))
		sem_palindromo = False
		break
	elif not is_palindrome(temp2):
		print(len(temp2))
		sem_palindromo = False
		break
	elif not is_palindrome(temp3):
		print(len(temp3))
		sem_palindromo = False
		break
if sem_palindromo:
	print(0)


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)


word = input()
if word == word[::-1]:
	kiemtra = 0
	c = word[0]
	for i in word:
		if c != i:
			kiemtra = 1
			break
	if kiemtra == 0:
		print(0)
	else:
		print(len(word) - 1)
else:
	print(len(word))


c = input()
print((len(c) - (c == c[::-1])) * (len(set(c)) > 1))


s = ''
s = input()

def rev(a):
	return a[::-1]
while 1:
	s2 = ''
	s2 = rev(s)
	if s != s2:
		print(len(s))
		break
	else:
		s = s[:-1]
		if s == '':
			print(0)
			break


s = input()
lenn = len(s)
if lenn == 1:
	print(0)
	quit()
e = lenn // 2
a = 0
if lenn % 2 != 0:
	e = e + 1
for i in range(1, e + 1):
	if s[:i] != s[-i:][::-1]:
		print(lenn)
		quit()
	elif s[i] == s[i - 1]:
		a += 1
	else:
		continue
if a == e:
	print(0)
else:
	print(lenn - 1)


def antipalindrome():
	x = input()
	max = 0
	k = 0
	if len(x) % 2 != 0:
		y = int((len(x) + 1) / 2)
	else:
		y = int(len(x) / 2)
	for i in range(len(x)):
		for j in range(i, y):
			if x[j] != x[len(x) - k - 1]:
				max = len(x) - i
				return max
			k = k + 1
		k = 0
		s = len(x) - i
		if s % 2 != 0:
			y = int((s + 1) / 2)
		else:
			y = int(s / 2)
	return max
print(antipalindrome())


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


s = input()
if len(set(s)) == 1:
	print(0)
elif len(s) % 2 == 0:
	k1 = list(s[0:int(len(s) / 2)])
	k2 = list(reversed(s[int(len(s) / 2):]))
	if k1 == k2:
		print(len(s) - 1)
	else:
		print(len(s))
else:
	k1 = list(s[0:int(len(s) / 2)])
	k2 = list(reversed(s[int(len(s) / 2) + 1:]))
	if k1 == k2:
		print(len(s) - 1)
	else:
		print(len(s))


s = input()

def is_pal(s, l):
	i = 0
	while i < l / 2:
		c1 = s[i]
		c2 = s[l - i - 1]
		if c1 != c2:
			return False
		i += 1
	return True
l = len(s)
ip = is_pal(s, l)
ip1 = is_pal(s, l - 1)
if not ip:
	print(l)
elif not ip1:
	print(l - 1)
else:
	print(0)


s = input()

def isPalindrome(s):
	l = len(s)
	for i in range(l // 2):
		if s[i] != s[l - i - 1]:
			return False
	return True
if not isPalindrome(s):
	print(len(s))
elif all([c == s[0] for c in s]):
	print(0)
else:
	print(len(s) - 1)


s = input()
a = list()
for i in range(0, len(s)):
	a.append(s[i])

def check(s):
	r = ''.join(reversed(s))
	if s == r:
		return 1
	else:
		return 0
x = check(s)
if x == 0:
	print(len(s))
else:
	while len(a) > 0:
		a.pop()
		s = ''.join(a)
		x = check(s)
		if x == 0:
			break
	print(len(s))


def solve():
	S = input()
	N = len(S)
	for n in reversed(range(1, N + 1)):
		for st in range(N - n + 1):
			if check(S[st:st + n]):
				print(n)
				return
	else:
		print('0')

def check(s):
	for i in range(len(s)):
		if s[i] != s[-i - 1]:
			return True
	else:
		return False
try:
	local_input()
except:
	pass
solve()


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


a = list(input())
b = a[:]
b.reverse()
c = list(set(a))
if len(c) == 1:
	print(0)
elif a == b:
	print(len(a) - 1)
else:
	print(len(a))


def ispal(l):
	return l == l[::-1]
s = str(input())
l = list(s)
n = len(l)
lenl = 0
for i in range(n):
	for j in range(i, n):
		ls = l[i:j + 1]
		if ispal(ls) == False:
			lenl = max(lenl, len(ls))
print(lenl)


s = input()
(l, ans) = (len(s), 0)
for i in range(l):
	x = s[i:]
	y = x[::-1]
	if x != y:
		ans = len(x)
		break
print(ans)


s = input()
l = len(s)
if s == l * s[0]:
	print(0)
else:
	checker = 0
	for (i, letter) in enumerate(s):
		j = -i - 1
		if s[i] != s[j]:
			checker = 1
			break
	if checker == 0:
		print(l - 1)
	else:
		print(l)


string = input()
chars = list(string)
if len(list(set(chars))) == 1:
	print(0)
	exit()
while 1:
	if len(chars) == 1:
		print(1)
		break
	if string != ''.join(reversed(string)):
		print(len(string))
		break
	string = string[:-1]


text = input()
ans = 0
for i in reversed(range(2, len(text) + 1)):
	for j in range(len(text) + 1 - i):
		subtext = text[j:j + i]
		if subtext != subtext[::-1]:
			ans = i
			break
	if ans != 0:
		break
print(ans)


a = input()
k = len(a)
f = 1
s = ''
for i in range(0, k):
	if a[0] != a[i]:
		f = 0
		break
if f == 1:
	print('0')
else:
	for i in range(k - 1, -1, -1):
		s = s + a[i]
	if s == a:
		k = k - 1
		print(k)
	else:
		print(k)


def pal():
	s = input()
	if s == s[::-1]:
		t = 0
		for i in range(len(s)):
			if s[0] == s[i]:
				t = t + 1
		if t == len(s):
			print('0')
		else:
			for i in range(1, len(s)):
				if s[:len(s) - i] != s[:len(s) - 1:-i]:
					print(len(s[:len(s) - i]))
					break
	else:
		print(len(s))
pal()


s = input()
ans = 0
n = len(s)
for i in range(n):
	for j in range(i + 1, n, 1):
		(a, b) = (i, j)
		flag = 0
		while a <= b:
			if s[a] != s[b]:
				flag = 1
				break
			a += 1
			b -= 1
		if flag == 1 and ans < j - i + 1:
			ans = j - i + 1
print(ans)


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


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


def pallndrome(xxx):
	xxx = str(xxx)
	le = len(xxx)
	a = []
	b = []
	if le % 2 == 0:
		for i in range(le):
			if i < le / 2:
				a.append(xxx[i])
			else:
				b.append(xxx[i])
		if a == b[::-1]:
			return 1
		else:
			return 0
	if le % 2 == 1:
		for i in range(le):
			if i < (le - 1) / 2:
				a.append(xxx[i])
			else:
				b.append(xxx[i])
		b.remove(b[0])
		if a == b[::-1]:
			return 1
		else:
			return 0
inp = input()
if len(set(inp)) == 1:
	print(0)
elif pallndrome(inp) == 0:
	print(len(inp))
elif pallndrome(inp) == 1:
	print(len(inp) - 1)


s = input()
x = set(s)
if len(x) == 1:
	print(0)
elif s == ''.join(reversed(s)):
	print(len(s) - 1)
else:
	print(len(s))


a = input()
n = len(a)
if a[:n // 2] == a[(n + 1) // 2:][::-1]:
	if a.count(a[0]) == n:
		print(0)
	else:
		print(n - 1)
else:
	print(n)


word = input()
dim = len(word)
nr = len(word)
found = False
while nr > 0:
	for i in range(0, dim - nr + 1):
		if word[i:nr + i] != word[i:nr + i][::-1]:
			print(nr)
			found = True
			break
	if found is True:
		break
	nr = nr - 1
if nr == 0:
	print(nr)


entrada = input()
cont = 0
cont1 = 0
for i in range(len(entrada)):
	for j in range(len(entrada) + 1):
		if i == j:
			continue
		elif entrada[i:j] != '':
			entrada1 = entrada[i:j]
			if entrada1 != entrada1[::-1]:
				cont = len(entrada1)
				if cont > cont1:
					cont1 = cont
print(cont1)


s = str(input())
lst = list()
lst_i = list()
for v in s:
	lst.append(v)
lst_i = lst[::-1]
while True:
	if len(lst) == 0:
		break
	if str(lst) == str(lst_i):
		lst.pop()
		lst_i = lst[::-1]
	else:
		break
print(len(lst))


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)


s = input()

def longest_non_p(s):
	if len(s) == 1:
		return 0
	if all((s[0] == i for i in s[1:])):
		return 0
	for i in range(len(s) // 2):
		if s[i] != s[-i - 1]:
			return len(s)
	return len(s) - 1
n = longest_non_p(s)
print('%d' % n)


word = input()
sts = {}

def pal(inp):
	global sts
	sts = {}
	t = True
	for x in range(int((len(inp) + 1) / 2)):
		if inp[x] == inp[0 - x - 1]:
			sts[inp[x]] = 0
		else:
			t = False
		x = round(len(inp) / 2) - 1
		sts[inp[x]] = 0
	return t
if pal(word) == False:
	print(len(word))
elif len(sts) == 1:
	print(0)
else:
	print(len(word) - 1)


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


s = input()
k = 0
flag = True
t = set()
for x in range(len(s) // 2 + 1):
	if s[x] != s[-(x + 1)]:
		flag = False
		break
	t.add(s[x])
if not flag:
	print(len(s))
elif len(t) == 1:
	print(0)
else:
	print(len(s) - 1)


a = input()
ans = 0
b = a
for i in range(len(a)):
	if a == a[::-1]:
		b = a[i:]
		if b != b[::-1]:
			ans = len(a) - i
			break
	elif a != a[::-1]:
		ans = len(a)
	elif a[i] == a[i - 1]:
		ans = 0
print(ans)


s = input()
s1 = s[::-1]
l = len(s)
if s1 != s:
	print(l)
else:
	i = l
	flag = 0
	while i >= 0:
		s = s[:i]
		s1 = s[::-1]
		if s != s1:
			print(len(s))
			flag = 1
			break
		i -= 1
	if flag == 0:
		print(0)


a = input()
max = 0
for i in range(len(a)):
	if a[0:i + 1] != a[i::-1] and max < i + 1:
		max = i
if max == 0:
	print(0)
else:
	print(max + 1)


from sys import stdin
trim = lambda s: s[:-1] if s[-1] == '\n' else s
s = trim(stdin.readline())
length = len(s)
while True not in [s[i:i + length] != s[i:i + length][::-1] for i in range(0, len(s) - length + 1)] and length > 0:
	length -= 1
print(length)


s = list(input())
w = s[:]
c = 0
w.reverse()
if w != s:
	print(len(s))
else:
	for q in range(len(s) - 1):
		if s[q] == s[q + 1]:
			c = c + 1
	if c == len(s) - 1:
		print(0)
	else:
		print(len(s) - 1)


def reverse(string):
	return string[::-1]

def findMinStr(input):
	newString = input
	while len(newString) > 0:
		newString = newString[:-1]
		if newString != reverse(newString):
			return len(newString)
	return 0
input = input()
if input != reverse(input):
	print(len(input))
else:
	print(findMinStr(input))


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 = list(input())

def palindrome(a):
	k = 0
	for i in range(len(a) // 2):
		if a[i] == a[len(a) - 1 - i]:
			k = k
		else:
			k = k + 1
	if k == 0:
		return True
	else:
		return False
i = len(s) - 1
while palindrome(s) and i >= 0:
	del s[i]
	i = i - 1
if len(s) > 0:
	print(len(s))
else:
	print(0)


def isPalyndrome(word):
	for i in range(len(word) // 2):
		if word[i] != word[len(word) - 1 - i]:
			return False
	return True
word = input()
while len(word) > 0:
	if not isPalyndrome(word):
		print(len(word))
		break
	else:
		word = word[:-1]
if len(word) == 0:
	print(0)


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


s = list(input())
(k, ln) = (len(set(s)), len(s))
if ln == 1 or k == 1:
	print(0)
elif k == ln or s != s[::-1]:
	print(ln)
else:
	for x in range(ln):
		s.pop()
		if s != s[::-1]:
			print(len(s))
			break
	else:
		print(0)


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


def is_palindrome(word):
	backwards = ''
	for i in range(len(word) - 1, -1, -1):
		backwards += word[i]
	if word == backwards:
		return True
	else:
		return False

def tudo_igual(word):
	letter = word[0]
	for e in word:
		if e != letter:
			return False
	return True
word = input()
if not is_palindrome(word):
	print(len(word))
elif tudo_igual(word):
	print(0)
else:
	print(len(word) - 1)


word = input()
if word != word[::-1]:
	print(len(word))
	exit()
n = len(word)
k = word[0]
if word.count(k) == len(word):
	print('0')
else:
	print(n - 1)


def reverse(s):
	return s[::-1]

def pal(s):
	rev = reverse(s)
	if s == rev:
		return 1
	return 0
str = input()
l = len(str)
c = 0
for i in range(0, l // 2 + 1):
	sub = str[i:]
	if pal(sub) == 0:
		print(len(sub))
		c = 1
		break
if c == 0:
	print(0)


def palindrome(n):
	c = 0
	for i in range(len(s) // 2):
		if s[i] != s[-1 - i]:
			c = 1
			break
	if c == 1:
		return False
	else:
		return True
s = str(input())
if len(s) == s.count(s[0]):
	print('0')
elif palindrome(s):
	print(len(s) - 1)
else:
	print(len(s))


s = input()
n = len(s)

def ap(s):
	for i in range(n // 2):
		if s[i] != s[n - i - 1]:
			return False
	return True
if ap(s) == False:
	print(n)
elif s.count(s[0]) == len(s):
	print('0')
else:
	print(n - 1)


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


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


def ispalindrome(s):
	n = len(s)
	for i in range(0, n // 2 + 1):
		if s[i] != s[n - 1 - i]:
			return False
	return True
s = str(input())
if not ispalindrome(s):
	print(len(s))
else:
	L = list(s)
	if all((e == L[0] for e in L)):
		print(0)
	else:
		print(len(s) - 1)


string = input()
v1 = 0
v2 = 0
for i in range(len(string)):
	for j in range(len(string) + 1):
		if i == j:
			continue
		elif string[i:j] != '':
			string1 = string[i:j]
			if string1 != string1[::-1]:
				v1 = len(string1)
				if v1 > v2:
					v2 = v1
print(v2)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
s = input()
if len(set(s)) == 1:
	print(0)
else:
	t = 0
	ls = len(s)
	for i in range(ls // 2):
		if s[i] == s[-i - 1]:
			t += 1
	if t == ls // 2:
		print(ls - 1)
	else:
		print(ls)


word = input()
rev_word = word[::-1]
size = 0
while len(word) != 0:
	if word != rev_word:
		size = len(word)
		break
	else:
		word = word[1:]
		rev_word = rev_word[-1:0:-1]
print(size)


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


s = input()

def is_palindrome(x):
	n = len(x) // 2
	for i in range(n):
		if x[i] != x[-i - 1]:
			return False
	return True
if len(set(s)) == 1:
	print(0)
elif is_palindrome(s):
	print(len(s) - 1)
else:
	print(len(s))


def pa(t):
	for i in range(len(t) // 2):
		if t[i] != t[len(t) - i - 1]:
			return False
	return True

def main():
	s = input()
	ans = 0
	for i in range(len(s)):
		for j in range(len(s)):
			t = s[i:j + 1]
			if not pa(t):
				if len(t) > ans:
					ans = len(t)
	print(ans)
main()


s = input()
if len(set(s)) == 1:
	print(0)
else:

	def compare(m, x, c, im):
		a = list(m)
		b = list(x)
		if a == b:
			a.remove(a[0])
		if im:
			b.append(c)
		return len(a) + len(b)
	if len(s) % 2:
		div = int((len(s) - 1) / 2)
		l = s[0:div]
		r = s[div + 1:len(s)]
		c = s[div]
		bp = 1
	else:
		div = int(len(s) / 2)
		l = s[0:div]
		r = s[div:len(s)]
		c = 0
		bp = 0
	mm = compare(l, reversed(r), c, bp)
	ww = compare(reversed(r), l, c, bp)
	print(mm if mm - ww >= 0 else ww)


inp = input()

def palindrome(num):
	return num == num[::-1]
i = 0
pal = False
while i < len(inp):
	j = len(inp) - 1
	while j >= i:
		if j - i + 1 == 1:
			print(0)
			pal = False
			break
		pal = palindrome(inp[i:j + 1])
		if pal == False:
			print(j - i + 1)
			break
		j -= 1
	if pal == False:
		break
i += 1


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


a = input()
x = len(a)
print([[x - 1, x][a[:x // 2] != a[:-1 - x // 2:-1]], 0][len({*a}) < 2])


def is_pal(S):
	for i in range(0, len(S)):
		if S[i] != S[-(i + 1)]:
			return False
	return True
while True:
	S = input()
	if not is_pal(S):
		print(len(S))
	elif S.count(S[0]) == len(S):
		print(0)
	else:
		print(len(S) - 1)
	break


a = input()
b = a[::-1]
c = ''.join(set(a))
if a == b and len(c) == 1:
	print('0')
elif a == b:
	print(len(a) - 1)
else:
	print(len(a))


s = input()
if len(set(s)) == 1:
	print(0)
else:
	length = len(s)
	if length % 2 == 0:
		if s[:length // 2] == s[length // 2:][::-1]:
			print(length - 1)
		else:
			print(length)
	elif s[:length // 2] == s[length // 2 + 1:][::-1]:
		print(length - 1)
	else:
		print(length)


a = input()
tt = ''
ans = ''
for i in range(len(a)):
	for j in range(i, len(a) + 1):
		cnt = a[i:j]
		for i in range(len(cnt)):
			tt += cnt[len(cnt) - i - 1]
		if cnt != tt:
			if len(cnt) > len(ans):
				ans = cnt
		cnt = ''
		tt = ''
print(len(ans))


import sys
import math as m
mod = 1000000000.0 + 7

def fi():
	return sys.stdin.readline()
s = fi().strip('\n')
n = len(s)
flag = 0
ans = n
flag = 0
i = 0
j = n - 1
while i < j:
	if s[i] != s[j]:
		flag = 1
		break
	i += 1
	j -= 1
if flag == 0 and len(set(s)) != 1:
	ans = n - 1
elif len(set(s)) == 1:
	ans = 0
print(ans)


i = list(input())
b = i[:]
e = i[:len(i) // 2]
if len(i) % 2 != 0:
	g = i[len(i) // 2 + 1:]
else:
	g = i[len(i) // 2:]
g.reverse()
if e == g:
	for x in range(0, len(b)):
		if b[0] != b[x]:
			print(len(i) - 1)
			exit()
	print(0)
	exit()
else:
	print(len(i))


s = str(input())
final = len(s) - 1
(i, tam) = (0, 0)

def ispalindrome(string):
	palindrome = True
	final = len(string) - 1
	for i in range(len(string) // 2):
		if string[i] != string[final]:
			palindrome = False
			break
		final -= 1
	return palindrome
for i in range(len(s)):
	if not ispalindrome(s):
		tam = len(s)
		break
	else:
		if s[i] != s[len(s) - 1]:
			tam = len(s) - i
			break
		elif s[0] != s[final]:
			tam = final + 1
			break
		final -= 1
if tam > 0 and tam < len(s):
	tam = len(s) - 1
print(tam)


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


s = input()
n = len(s)
m = int(n / 2)
c = 0
a = 0
for i in range(m):
	if s[i] == s[n - i - 1]:
		continue
	else:
		c = 1
		break
for i in range(n - 1):
	if s[i] == s[i + 1]:
		continue
	else:
		a = 1
		break
if a == 0:
	print(0)
elif c == 0:
	print(n - 1)
else:
	print(n)


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


s = input()
k = s

def rev(s):
	a = ''
	for i in range(len(s) - 1, -1, -1):
		a += s[i]
	return a
while k == rev(k) and len(k) > 0:
	k = k[:-1]
else:
	print(len(k))


import math as mt
import sys, string
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def printARR(arr):
	for e in arr:
		print(e, end=' ')
	print()

def isP(s):
	return s == s[::-1]

def main():
	s = input()
	if s.count(s[0]) == len(s):
		print(0)
	elif isP(s):
		print(len(s) - 1)
	else:
		print(len(s))
tc = 1
for _ in range(tc):
	main()


s = input(str())
index = 1
while index and len(s):
	if s == s[::-1]:
		s = s[:-1]
	else:
		print(len(s))
		index = 0
if index:
	if len(s) == 0:
		print(0)


def isPalindrome(s):
	rev = ''.join(reversed(s))
	if s == rev:
		return True
	return False
s = input()
ans = isPalindrome(s)
if not ans:
	print(len(s))
else:
	from collections import Counter
	c = Counter(list(s))
	if len(c) == 1:
		print(0)
	else:
		print(len(s) - 1)


l = list(map(str, input().replace('', ' ').split()))

def pali(l):
	s = l[:]
	s.reverse()
	if l != s:
		return True
	else:
		return False
a = [0]
for i in range(len(l)):
	for j in range(i + 1, len(l) + 1):
		if pali(l[i:j]):
			a.append(len(l[i:j]))
print(max(a))


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


b = input()
m = len(b) - 1
s = len(b) // 2
entrar = 1
conse = 1
eje = b[0]
for k in range(s):
	if b[k] != b[m]:
		entrar = 0
		print(len(b))
		break
	m = m - 1
if entrar == 1:
	u = b.count(b[0])
	if u == len(b):
		print(0)
	else:
		print(len(b) - 1)


string = input()
for i in range(len(string)):
	for j in range(len(string), i - 1, -1):
		if string[i:j] == string[j - len(string) - 1:-len(string) + i - 1:-1]:
			continue
		else:
			print(len(string[i:j]))
			exit()
print(0)


def rasturnat(y):
	return y[::-1]

def palindrom(x):
	if x == rasturnat(x):
		return True
	return False

def stabilire(variabila):
	left = variabila[1:]
	right = variabila[:len(variabila) - 1]
	if palindrom(left) and len(left) > 1:
		return stabilire(left)
	elif palindrom(left) == False:
		return len(left)
	if palindrom(right) and len(right) > 1:
		return stabilire(right)
	elif palindrom(right) == False:
		return len(right)
	return 0
fraza = input()
nou = palindrom(fraza)
if nou == True:
	lungime = stabilire(fraza)
	print(lungime)
else:
	print(len(fraza))


def isPal(string):
	if string[::-1] == string:
		return True
	else:
		return False
string = input()
length = len(string)
max_len = len(string)
found = False
while max_len != 0:
	for i in range(length - max_len + 1):
		temp = string[i:i + max_len]
		if not isPal(temp):
			found = True
			break
	if found:
		break
	else:
		max_len -= 1
print(max_len)


s = list(input())
sure = True
if len(set(s)) == 1:
	print(0)
else:
	for i in s:
		if s.count(i) > 1:
			sure = False
			break
	if sure:
		print(len(s))
if not sure:
	while s == s[::-1]:
		if s[0] == s[len(s) - 1]:
			del s[len(s) - 1]
		else:
			break
	print(len(s))


x = input()
ar = []
d = []
k = 0
for i in x:
	k = k + 1
	ar.append(i)
ar.reverse()
for j in x:
	d.append(j)
if d == ar:
	if d.count(d[0]) == k:
		print('0')
	else:
		print(k - 1)
else:
	print(k)


s = input()

def check_palindrome(s):
	return s == s[::-1]

def main(s):
	i = 0
	for i in range(len(s)):
		if not check_palindrome(s[:len(s) - i]):
			return len(s[:len(s) - i])
		if not check_palindrome(s[i:]):
			return len(s[i:])
	return 0
print(main(s))


a = input()
i = len(a)
while i > 0 and a[:i] == a[i - 1::-1]:
	i -= 1
print(i)


s = input()
count = 0
k = s[::-1]
n = len(s)
a = n
while s == k:
	k = k.replace(k[n - 1], '', 1)
	count += 1
	n -= 1
	if k == '':
		break
	s = k[::-1]
print(a - count)


def is_palindrome(S):
	length = len(S)
	result = True
	for i in range(len(S) // 2):
		if S[i] != S[length - i - 1]:
			result = False
			break
	return result
s = input()
n = len(s)
yes = False
for i in range(n):
	for j in range(n - 1, i, -1):
		if not is_palindrome(s[i:j + 1]):
			print(j - i + 1)
			yes = True
			break
	if yes:
		break
if not yes:
	print(0)


import re
import sys
s = input()
if s == s[::-1]:
	s = s.replace(s[-1], '', 1)
	if s == s[::-1]:
		print('0')
	else:
		print(len(s))
else:
	print(len(s))


def pan(strr):
	stri = strr[::-1]
	if stri == strr:
		return 0
	else:
		return len(stri)
a = input()
b = len(a)
c = 1
f = []
while c <= b:
	d = c
	while d <= b:
		g = a[c - 1:d]
		f = f + [pan(g)]
		d += 1
	c += 1
f.sort()
print(f[-1])


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


c = input()
count = 0
for i in range(len(c)):
	if c[i:] == c[i:][::-1]:
		count += 1
	else:
		break
print(len(c) - count)


s = input()
n = len(s)
flag = 0
for i in range(0, n):
	s2 = s[i:n]
	if s2 != s2[::-1]:
		print(n - i)
		flag = 1
		break
if flag == 0:
	for i in range(0, n):
		s2 = s[0:n - i]
		if s2 != s2[::-1]:
			print(n - i)
			flag = 1
			break
if flag == 0:
	print('0')


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))
elif onl:
	print(0)
else:
	print(len(s) - 1)


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	st = list(input())
	n = len(st)
	res = 0
	for i in range(n):
		for j in range(i + 1, n + 1):
			if st[i:j] != list(reversed(st[i:j])):
				res = max(res, j - i)
	print(res)
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


s = list(input())

def f(s):
	l = 0
	for i in range(len(s)):
		if s[i:] != s[i:][::-1]:
			l = len(s) - i
			break
	return l
print(max(f(s), f(s[::-1])))


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


n = input()
x = list(reversed(n))
t = 0
for i in range(len(x)):
	if n[i] != x[i]:
		t = 1
if t == 0:
	if x.count(x[0]) == len(x):
		print('0')
	else:
		print(len(x) - 1)
else:
	print(len(x))


s = input()
s = list(s)
cnt = len(s)
if len(set(s)) == 1:
	print(0)
else:
	while True:
		if s == s[::-1]:
			s.pop()
			cnt -= 1
		else:
			break
	print(cnt)


S = input()
i = 0
b = 0
number = 0
while i <= len(S):
	while b < len(S):
		string = S[i:b + 1]
		if string != string[::-1]:
			if number < len(string):
				number = len(string)
		b += 1
	b = i + 1
	i += 1
print(number)


s = input()
if len(set(s)) == 1:
	print(0)
else:
	a = []
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			v = ''
			v = s[i:j + 1]
			if v != v[::-1] and v not in a:
				a.append(v)
	for i in range(len(a)):
		a[i] = len(a[i])
	print(max(a))


def ispalindrome(s):
	for i in range(len(s) // 2):
		if s[i] != s[len(s) - 1 - i]:
			return False
	else:
		return True
s = input()
if len(set(s)) == 1:
	print(0)
elif ispalindrome(s):
	print(len(s) - 1)
else:
	print(len(s))


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()
if s == s[::-1]:
	count = 0
	while s == s[::-1] and s:
		s = s[:len(s) - 1]
		count = len(s)
	print(count)
else:
	print(len(s))


s = str(input())
if s != s[::-1]:
	print(len(s))
else:
	flag = 0
	for i in range(1, len(s)):
		d = s[i:]
		if d != d[::-1]:
			flag = 1
			break
		else:
			pass
	if flag > 0:
		print(len(s) - i)
	else:
		print(0)


word = input()
cword = word[len(word) // 2:len(word)]
if word.count(word[0]) == len(word):
	print('0')
elif word[0:len(cword)] == cword[::-1]:
	print(len(word) - 1)
else:
	print(len(word))


def isPal(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True
s = input()
if isPal(s) == True:
	if s.count(s[0]) == len(s):
		print(0)
	else:
		print(len(s) - 1)
else:
	print(len(s))


str = input()
c = 1
if str == str[::-1]:
	for i in range(len(str) - 1):
		if str[i] == str[i + 1]:
			c += 1
	if c == len(str):
		print(0)
	else:
		print(len(str) - 1)
else:
	print(len(str))


string = input()
array = list()
n = 0
for c in string:
	if not c in array:
		array.append(c)
		n += 1
if string == string[::-1] and n > 1:
	print(len(string) - 1)
elif n == 1:
	print(0)
elif string != string[::-1]:
	print(len(string))


s = input()
flag = 1
for i in range(int(len(s) / 2)):
	if s[i] != s[len(s) - 1 - i]:
		flag = 0
		break
same = 1
for i in range(1, len(s)):
	if s[i] != s[0]:
		same = 0
		break
if flag == 1 and same == 1:
	print('0')
elif flag == 1 and same == 0:
	print(len(s) - 1)
elif flag == 0:
	print(len(s))


def EsPalindromo(S, i, j):
	EsPali = True
	while i <= j:
		if S[i] != S[j]:
			EsPali = False
			break
		i += 1
		j -= 1
	return EsPali
S = str(input())
i = 0
j = len(S) - 1
while i < j:
	if EsPalindromo(S, i, j) == False:
		print(j - i + 1)
		break
	j -= 1
if i >= j:
	print('0')


s = input()
a = list(s)
a.reverse()
b = ''.join(a)
if b != s:
	print(len(s))
elif s.count(s[0]) == len(s):
	print(0)
else:
	print(len(s) - 1)


s = input().strip()
for i in range(len(s)):
	for j in range(len(s) - 1, i, -1):
		for k in range(0, (j - i + 1) // 2):
			if s[i + k] != s[j - k]:
				print(j - i + 1)
				exit()
print(0)


def antipal(s):
	if s != s[::-1]:
		return len(s)
	else:
		while s[::-1] == s and len(s) != 1:
			s = s[:-1]
		if len(s) == 1:
			return 0
		else:
			return len(s)
s = input()
print(antipal(s))


string = input()
string_rev = string[::-1]
tmp = 0
for i in range(1, len(string)):
	if string[i] != string[0]:
		tmp = 1
if tmp == 0:
	print(0)
elif string == string_rev:
	print(len(string) - 1)
else:
	print(len(string))


s = input()
for i in range(len(s)):
	t = s[i:]
	m = s[:len(s) - i]
	l = len(t)
	if l == 1:
		print(0)
		exit()
	if t[:(l + 1) // 2] != t[l - 1:l // 2 - 1:-1] or m[:(l + 1) // 2] != m[l - 1:l // 2 - 1:-1]:
		print(l)
		exit()


def anti(s):
	c = 0
	if s != s[::-1]:
		return len(s)
	else:
		for i in range(len(s)):
			c += 1
			if s[i + 1:] != s[:i:-1]:
				return len(s) - (i + 1)
	if c == len(s):
		return 0
s = input()
x = anti(s)
print(x)


x = input()
y = x[::-1]

def asd(x):
	a = x
	b = x[::-1]
	if a == b and x != '':
		x = x[:len(x) - 1]
		asd(x)
	elif a != b or x == '':
		print(len(x))
asd(x)


s = input()

def check(s):
	m = len(s) // 2
	if len(s) % 2 == 0:
		t = s[m:]
		if s[:m] == t[::-1]:
			return True
	else:
		t = s[m + 1:]
		if s[:m] == t[::-1]:
			return True
	return False
flag = check(s)
while flag and len(s) > 0:
	s = s[1:]
	flag = check(s)
print(len(s))


import collections
s = input()
c1 = collections.Counter(s)

def checkPalindrome(s):
	l = list(s)
	l1 = l[0:len(s) // 2]
	if len(s) % 2 == 0:
		l2 = l[len(s):len(s) // 2 - 1:-1]
	else:
		l2 = l[len(s):len(s) // 2:-1]
	return l1 == l2
if checkPalindrome(s) and len(c1) > 1:
	print(len(s) - 1)
elif len(c1) == 1:
	print(0)
else:
	print(len(s))


def is_palindrome(string):
	result = True
	str_len = len(string)
	for i in range(0, int(str_len / 2)):
		if string[i] != string[str_len - i - 1]:
			result = False
			break
	return result
s = str(input())
k = s[0]
check = False
for i in range(len(s)):
	if k != s[i]:
		check = True
if check == False:
	print(0)
elif is_palindrome(s) == True:
	print(len(s) - 1)
else:
	print(len(s))


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


a = input()
k = a[1:]
lst = []
s = a[0]
for t in k:
	s = s + t
	d = s[::-1]
	if s != d:
		lst.append(s)
if len(lst) == 0:
	print('0')
else:
	print(len(max(lst, key=len)))


s = input()
if s != s[::-1]:
	print(len(s))
	exit(0)
p = s[0] * len(s)
if p == s:
	print(0)
	exit(0)
print(len(s) - 1)


k = input()
if len(k) % 2 == 0:
	t = int(len(k) / 2)
else:
	t = int((len(k) - 1) / 2)
i = 0
flag = 1
for i in range(t):
	if k[i] != k[len(k) - i - 1]:
		print(str(len(k)))
		flag = 0
		break
if flag == 1:
	if k.count(k[0]) == len(k):
		print(0)
	else:
		print(str(len(k) - 1))


from collections import Counter
s = list(input())
if len(s) == 1:
	print(0)
	exit()
if s != s[::-1]:
	print(len(s))
	exit()
while s == s[::-1]:
	if s and s[0] == s[-1]:
		s.pop(-1)
	if len(s) == 0:
		print(0)
		exit()
print(len(s))


word = [i for i in input()]
if word.count(word[0]) == len(word):
	print(0)
elif len(word) % 2 == 0:
	m = len(word) // 2
	if word[:m] == word[m:][::-1]:
		print(len(word) - 1)
	else:
		print(len(word))
else:
	m = len(word) // 2 + 1
	if word[:m - 1] == word[m:][::-1]:
		print(len(word) - 1)
	else:
		print(len(word))


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


a = input()
b = a[::-1]
c = 0
if a != b:
	print(len(a))
while a == b:
	a = a[:0] + a[0 + 1:]
	b = a[::-1]
	if a != b:
		print(len(a))
	else:
		print(c)
		break


def code2(a):
	b = a[::-1]
	c = len(a)
	if c == a.count(a[0]):
		c = 0
	elif a == b:
		c -= 1
	print(c)
code2(input())


def allSame(a):
	i = 0
	while i < len(a) - 1:
		if a[i] == a[i + 1]:
			i += 1
		else:
			return False
	return True
a = input()
b = a[::-1]
if allSame(a):
	print(0)
elif b == a:
	print(len(a) - 1)
else:
	print(len(a))


s = input().strip()
rev = s[::-1]
le = len(set(s))
if le == 1:
	print(0)
elif s == rev:
	print(len(s) - 1)
else:
	print(len(s))


def isPalin(t):
	u = ''
	for i in t:
		u = i + u
	if u == t:
		return True
	else:
		return False
s = input()
n = len(s)
i = 0
for i in range(n - 1, -1, -1):
	f = 0
	if s[0] != s[i]:
		f = 1
	else:
		S = s[:i + 1]
		if not isPalin(S):
			f = 1
	if f == 1:
		break
if i == 0:
	print(i)
else:
	print(i + 1)


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


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()


l = []
a = input()
for i in range(len(a)):
	for j in range(len(a), i, -1):
		b = a[i:j]
		c = b[::-1]
		if b == c:
			pass
		else:
			l += [len(b)]
else:
	if len(l) > 0:
		print(max(l))
	else:
		print('0')


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


import sys
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)


s = input()

def isP(x):
	if x == x[::-1]:
		return True
	else:
		return False
while isP(s) and len(s) > 0:
	s = s[1:]
print(len(s))


def notPalindrome(s):
	return s != s[::-1]
s = input()
done = False
for l in range(len(s), 0, -1):
	for i in range(len(s) - l + 1):
		if notPalindrome(s[i:i + l]):
			print(l)
			done = True
			break
	if done:
		break
if not done:
	print('0')


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


x = input()
x1 = x[::-1]
if x != x1:
	print(len(x))
else:
	x1 = x1.replace(x1[0], '', 1)
	x2 = x1[::-1]
	if x2 != x1:
		print(len(x1))
	else:
		print('0')


s = input()
zero = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		pass
	else:
		zero += 1
if zero == 0:
	print(0)
	exit()
elif s != s[::-1]:
	print(len(s))
else:
	print(len(s) - 1)


(s, r) = (input(), 0)
i = len(s)
while i > r:
	for j in range(i - r):
		t = s[j:i]
		if t != t[::-1]:
			r = i - j
			break
	i -= 1
print(r)


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


from math import *

def check(s, Le, Ri):
	while Le < Ri:
		if s[Le] != s[Ri]:
			return True
		Le += 1
		Ri -= 1
	return False

def main():
	s = input()
	flag = True
	for i in range(len(s) - 1):
		if s[i] != s[i + 1]:
			flag = False
			break
	if flag:
		print(0)
	else:
		ans = -1
		for i in range(len(s) - 1):
			for j in range(i + 1, len(s)):
				if check(s, i, j):
					ans = max(ans, j - i + 1)
		print(ans)
try:
	while True:
		main()
except EOFError:
	pass


s = input()
c1 = 0
c2 = 0
for i in range(len(s)):
	for j in range(len(s) + 1):
		if i == j:
			continue
		elif s[i:j] != '':
			s1 = s[i:j]
			if s1 != s1[::-1]:
				c1 = len(s1)
				if c1 > c2:
					c2 = c1
print(c2)


s = input()

def safe(x, n):
	if x < 0 or x >= n:
		return False
	return True

def fun(s, l, r, n):
	ans = 0
	t = 0
	flag = 0
	while safe(l, n) and safe(r, n):
		if s[l] != s[r] or flag == 1:
			t += 2
			ans = t
			flag = 1
		else:
			t += 2
		l -= 1
		r += 1
	return ans
m = 0
for i in range(len(s)):
	if safe(i + 1, len(s)):
		m = max(m, fun(s, i, i + 1, len(s)))
	if safe(i + 2, len(s)):
		tt = fun(s, i, i + 2, len(s))
		if tt > 0:
			tt += 1
		m = max(m, tt)
print(m)


s = input()
a = []
for i in range(len(s)):
	a.append(s[i])
x = list(reversed(a))
if x == a:
	b = []
	b = list(a)
	b.pop()
	x = list(reversed(b))
	if x == b:
		print(0)
	else:
		print(len(b))
else:
	print(len(a))


s = input().strip()
max_s = 0
for char in range(len(s) - 1):
	for p in range(char, len(s) - 1):
		s2 = s[p:]
		if s2 != s2[::-1]:
			if len(s2) > max_s:
				max_s = len(s2)
print(max_s)


a = input()
b = len(a)

def pal(a):
	return a == a[::-1]
for i in range(b):
	if pal(a[i:]):
		b -= 1
	else:
		break
print(b)


def antipalindrome(s):
	i = len(s) - 1
	if s != s[::-1]:
		return len(s)
	elif len(s) == 0:
		return 0
	return antipalindrome(s[:i])
s = input()
print(antipalindrome(s))


s = input()
i = len(s)
while i > 0:
	if s[:i] != s[i - 1::-1]:
		print(len(s[:i]))
		exit()
	i -= 1
print(0)


s = str(input())
max_length = 0
for x in range(0, len(s) - 1):
	for y in range(x + 1, len(s)):
		m = s[x:y + 1]
		n = m[::-1]
		if m != n:
			if len(m) > max_length:
				max_length = len(m)
print(max_length)


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


x = input()
ar = []
b = []
for i in x:
	ar.append(i)
for j in x:
	b.append(j)
ar.reverse()
if x.count(x[0]) != len(x):
	if b == ar:
		print(len(b) - 1)
	else:
		print(len(b))
else:
	print('0')


s = input().strip()
temp = s[::-1]
if len(set(s)) == 1:
	print(0)
elif s == temp:
	print(len(s) - 1)
elif s != temp:
	print(len(s))


def reverse(s):
	return s[::-1]

def isPalindrome(s):
	rev = reverse(s)
	if s == rev:
		return True
	return False
s = str(input())
n = len(s)
ans = 0
for i in range(n):
	for j in range(i, n):
		temp = s[i:j + 1]
		if isPalindrome(temp) == False:
			ans = max(ans, len(temp))
print(ans)


def ispal(a):
	q = ''
	for i in range(len(a) - 1, -1, -1):
		q += a[i]
	if a == q:
		return 1
	else:
		return 0
a = input()
fnd = 0
for i in range(len(a), 0, -1):
	for j in range(0, len(a) - i + 1):
		if not ispal(a[j:j + i]):
			print(i)
			fnd = 1
			break
	if fnd:
		break
if not fnd:
	print(0)


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


s = input()
c = len(s)
for i in range(len(s) - 1, 0, -1):
	k = s[0:i + 1]
	if k != k[::-1]:
		print(c)
		exit()
	c -= 1
if c == 1:
	print('0')


s = list(input())
n = len(s)

def check(a):
	n = len(a)
	for i in range(n // 2):
		if a[i] != a[-i - 1]:
			return True
	return False
ans = 0
for i in range(n):
	for j in range(i, n):
		if check(s[i:j + 1]):
			ans = max(ans, j - i + 1)
print(ans)


X = input()
print(0 if len(set(X)) == 1 else len(X) if X != ''.join(reversed(X)) else len(X) - 1)


import sys
pin = sys.stdin.readline
pout = sys.stdout.write
ran = range
t = input()
string = t[::-1]
if t == string and t.count(t[0]) != len(t):
	print(len(t) - 1)
if t == string and t.count(t[0]) == len(t):
	print(0)
if t != string:
	print(len(t))


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


inp = input()

def palindrome(num):
	return num == num[::-1]
len_non_palyndrom = 0
if not palindrome(inp):
	print(len(inp))
else:
	for i in range(len(inp)):
		if not palindrome(inp[:-i]):
			len_non_palyndrom = len(inp) - i
			break
	print(len_non_palyndrom)


def is_palin(s):
	l = len(s)
	for i in range(l // 2):
		if not s[i] == s[l - i - 1]:
			return False
	return True
inp = str(input())
n = len(inp)
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		if not is_palin(inp[i:j + 1]) and j - i + 1 > ans:
			ans = j - i + 1
print(ans)


string = input()
palindrome = True
length = len(string)
while palindrome and length > 0:
	half = length // 2
	if length % 2 == 0:
		if string[:half] != string[half:length][::-1]:
			palindrome = False
		else:
			length -= 1
	elif string[:half] != string[half + 1:length][::-1]:
		palindrome = False
	else:
		length -= 1
print(length)


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


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


Input = lambda : map(int, input().split())
s = input()
t = reversed(s)
F = False
for (i, j) in zip(t, s):
	if i != j:
		F = True
		break
if F == False:
	if len(set(s)) == 1:
		print(0)
	else:
		print(len(s) - 1)
else:
	print(len(s))


def isPalindrome(s):
	return s == s[::-1]

def allCharSame(s):
	return len(set((c for c in s))) == 1
s = input()
if allCharSame(s):
	print(0)
elif isPalindrome(s):
	print(len(s) - 1)
else:
	print(len(s))


def isPalindrome(x):
	n = len(x)
	a = x[:n // 2]
	b = ''.join([x[-i] for i in range(1, n // 2 + 1)])
	return a == b
s = input()
n = len(s)
while n > 0 and isPalindrome(s[:n]):
	n -= 1
print(n)


a = list(map(str, input()))
b = set(a)
if len(b) == 1:
	print(0)
elif a[::-1] == a:
	print(len(a) - 1)
else:
	print(len(a))


s = input()
n = len(s)
i = n
flag = 0
while i >= 0:
	a = s[0:i]
	if a != a[::-1]:
		flag = 1
		print(i)
		break
	i = i - 1
i = 0
while i < n and flag == 0:
	a = s[i:n]
	if a != a[::-1]:
		flag = 1
		print(n - 1)
		break
	i = i + 1
if flag == 0:
	print('0')


s = str(input())
if len(set(s)) == 1:
	print(0)
else:
	l = len(s)
	n = l // 2
	if s[:n] == s[n + l % 2:][::-1]:
		print(l - 1)
	else:
		print(l)


s = input()
k = len(s)
r = 0
a = 0
if k % 2 == 0:
	r = k // 2
	a = k // 2
else:
	r = k // 2 + 1
	a = k // 2 + 1
l = s[0:r]
p = s[-1:-a - 1:-1]
if l != p:
	print(k)
else:
	f = 0
	for i in range(k - 1):
		if s[i] != s[i + 1]:
			f = 1
	if f == 0:
		print(0)
	else:
		print(k - 1)


s = input()
x = []
for i in range(len(s)):
	a = s[i]
	for j in range(i + 1, len(s)):
		a += s[j]
		x.append(a)
if len(x) > 0:
	prev = 0
	ans = ''
	for i in range(len(x)):
		w = x[i]
		r = w[::-1]
		f = 0
		for j in range(len(w)):
			if w[j] != r[j]:
				f = 1
				break
		if f == 1:
			if prev < len(w):
				prev = len(w)
				ans = w
	if len(ans) == 0:
		print('0')
	else:
		print(len(ans))
else:
	print('0')


def palindrome(a):
	if len(a) == 0:
		return False
	for i in range(len(a) // 2):
		if a[i] == a[len(a) - 1 - i]:
			continue
		else:
			return False
	return True

def fun(a):
	k = palindrome(a)
	if k == False:
		l = len(a)
		return l
	else:
		l = len(a)
		b = a[:l - 1]
		return fun(b)
s = input()
print(fun(s))


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	s = st()
	n = len(s)
	q = s[0]
	if s.count(q) == n:
		pr(0)
	elif s == s[::-1]:
		pr(n - 1)
	else:
		print(n)
for _ in range(1):
	solve()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())

def isPallindrome(s):
	flag = True
	for i in range(len(s) // 2):
		if s[i] != s[~i]:
			flag = False
			break
	return flag
string = get_string()
if isPallindrome(string):
	if len(set(string)) > 1:
		print(len(string) - 1)
	else:
		print(0)
else:
	print(len(string))


st = list(input())
i = 0
j = len(st) - 1
while i < j and st[i] == st[j]:
	i += 1
	j -= 1
if not j - i < 1:
	print(len(st))
	quit()
f = True
for i in range(1, len(st)):
	if st[i] != st[i - 1]:
		f = False
		break
if f:
	print(0)
else:
	print(len(st) - 1)


def isP(s):
	for x in range(len(s) // 2):
		if s[x] != s[len(s) - 1 - x]:
			return False
	return True
S = input()
while len(S) > 0:
	if isP(S) == False:
		print(len(S))
		break
	else:
		S = S[:-1]
if S == '':
	print(0)


s = input()
c = s[0]
n = len(s)
if s.count(c) == n:
	print('0')
else:
	i = 0
	ok = 0
	while not ok and i < n // 2:
		if s[i] != s[n - i - 1]:
			ok = 1
		i += 1
	if ok:
		print(n)
	else:
		print(n - 1)


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


import sys
s = input()
n = len(s)
for i in range(n, 0, -1):
	for start in range(0, n):
		if start + i > n:
			continue
		if s[start:start + i] != s[start:start + i][::-1]:
			print(i)
			sys.exit()
print(0)


import sys, math, os.path
FILE_INPUT = 'A.in'
DEBUG = os.path.isfile(FILE_INPUT)
if DEBUG:
	sys.stdin = open(FILE_INPUT)

def ni():
	return map(int, input().split(' '))

def nia():
	return list(map(int, input().split()))

def log(x):
	if DEBUG:
		print(x)
s = input()

def test(s, ls, length):
	if length < 2:
		return 0
	for i in range(ls - length + 1):
		ss = s[i:i + length]
		if ss != ss[::-1]:
			return True
	return False

def find(s):
	ls = len(s)
	for leng in range(ls, 1, -1):
		if test(s, ls, leng):
			return leng
	return 0
print(find(s))


s = input()
output = 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]:
			output = max(output, r - l + 1)
print(output)


paln = input()
if paln != paln[::-1]:
	print(len(paln))
else:
	pallen = 0
	if len(set(paln)) == 1:
		print(0)
	else:
		for i in range(len(paln) - 1, 0, -1):
			if paln[0:i] == paln[0:i:-1]:
				break
			else:
				pallen += 1
		print(pallen)


l = list(input())
if len(set(l)) == 1:
	print(0)
	exit()
x = l[:]
x.reverse()
if l == x:
	print(len(l) - 1)
	exit()
if l != x and len(set(l)) != 1:
	print(len(l))


A = input()
n = len(A)
B = A[::-1]
if A == B:
	if len(set(A)) == 1:
		ans = 0
	else:
		ans = n - 1
else:
	ans = n
print(ans)


def checkP(string):
	if string == string[len(string) - 1:0:-1] + string[0]:
		return True
	return False

def solve():
	string = input()
	n = len(string)
	(i, j, count) = (0, 0, 0)
	if n == 2:
		if string[0] == string[1]:
			return 0
		return 2
	if n == 1:
		return 0
	while i < n - 2:
		j = n
		while j > i:
			if checkP(string[i:j]) == False:
				count = abs(j - i)
				return count
			j -= 1
		i += 1
	return 0
print(solve())


s = input()

def main():
	letters = set()
	for letter in s:
		letters.add(letter)
	if len(letters) == 1:
		return 0
	l = len(s)
	is_polindrom = True
	for i in range(l // 2):
		if s[i] != s[l - 1 - i]:
			is_polindrom = False
			break
	if is_polindrom == False:
		return l
	else:
		return l - 1
result = main()
print(result)


def isPalinDrome(s):
	for i in range(len(s)):
		if s[i] == s[-i - 1]:
			continue
		else:
			return False
	return True

def findRecursivly(s, length):
	palinDrome = isPalinDrome(s)
	if not palinDrome or length == 0:
		return length
	else:
		return findRecursivly(s[:length - 1], length - 1)
s = input()
subStringLen = len(s)
result = findRecursivly(s, subStringLen)
print(result)


b = str(input())
a = b.casefold()
n = len(a)
p = 0
if n % 2 == 0:
	m = n // 2
else:
	m = n // 2 + 1
for i in range(m):
	if a[i] != a[n - i - 1]:
		p = 1
if p == 0:
	if a.count(a[0]) != n:
		print(n - 1)
	else:
		print(0)
else:
	print(n)


t = input()
if len(set(t)) == 1:
	print(0)
else:
	print(len(t) - 1 if ''.join(list(reversed(t))) == t else len(t))


st = input()
if len(set(st)) == 1:
	print(0)
elif st == ''.join(reversed(st)):
	print(len(st) - 1)
else:
	print(len(st))


import sys
from functools import lru_cache

@lru_cache(maxsize=None)
def sol(s):
	if not s:
		return 0
	if is_palindrome(s):
		return min(sol(s[:-1]), sol(s[1:]))
	else:
		return len(s)

def is_palindrome(s):
	if len(s) <= 1:
		return True
	return s[0] == s[-1] and is_palindrome(s[1:-1])
s = sys.stdin.readline().strip()
print(sol(s))


a = input()
c = []
for i in range(len(a)):
	c.insert(i, a[i])
b = list(reversed(a))
if c != b:
	print(len(a))
else:
	count = 0
	for i in range(len(a)):
		if i < len(a) - 1:
			if a[i] != a[i + 1]:
				print(len(a) - 1)
				break
			else:
				count += 1
	if count == len(a) - 1:
		print('0')


a = str(input())
s = 0
for i in range(0, len(a) + 1):
	for j in range(i, len(a) + 1):
		b = a[i:j + 1]
		c = b[::-1]
		if b != c:
			s = max(s, len(b))
if s == 0:
	print(0)
else:
	print(s)


s = input()
res = 0
for i in range(len(s)):
	for j in range(i + 1, len(s) + 1):
		ws = True
		for k in range(0, j - i):
			if s[i + k] != s[j - k - 1]:
				ws = False
		if not ws:
			res = max(res, j - i)
print(res)


a = list(input())
h = len(a)
if len(set(a)) == 1:
	print(0)
else:
	l = 0
	for k in range(len(a)):
		t = a[k:]
		s = h - k
		if s % 2 == 0:
			if a[k:k + s // 2] == a[k + s // 2:][::-1]:
				pass
			elif s > l:
				l = s
		elif a[k:k + s // 2] == a[k + s // 2 + 1:][::-1]:
			pass
		elif s > l:
			l = s
	print(l)


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


def ispalindrome(s):
	for i in range(int(len(s) / 2)):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True

def allCharactersSame(s):
	n = len(s)
	for i in range(n):
		if s[i] != s[0]:
			return False
	return True
s = input()
if ispalindrome(s) == False:
	print(len(s))
elif allCharactersSame(s) == True:
	print('0')
else:
	print(len(s) - 1)


R = lambda : map(int, input().split())
s = input()
if len(set(s)) == 1:
	print(0)
elif s != s[::-1]:
	print(len(s))
else:
	for i in range(len(s)):
		if s[i + 1:] != s[i + 1:][::-1]:
			print(len(s[i + 1:]))
			break
	else:
		print(0)


s = input()
ans = 0
n = len(s)
dp = [[True for _ in range(n)] for __ in range(n)]
for l in range(1, n):
	for ed in range(l, n):
		st = ed - l
		dp[st][ed] = s[st] == s[ed]
		if l > 1:
			dp[st][ed] &= dp[st + 1][ed - 1]
		if not dp[st][ed]:
			ans = l + 1
print(ans)


t = ''
t = input()
s = t
r = t[::-1]
l = []
l = list(s)
n = len(l)
if len(t) == l.count(l[0]):
	print('0')
for i in range(n):
	k = ''
	for j in range(len(l)):
		k = k + l[j]
	if k != k[::-1]:
		print(len(k))
		break
	else:
		del l[0]


s = input()
sl = [i for i in s]
x = set(sl)
if len(x) == 1:
	print(0)
elif sl != sl[::-1]:
	print(len(s))
else:
	print(len(s) - 1)


s = str(input()).lower()
i = s[::-1]
if s == i:
	lista = list()
	for c in s:
		lista.append(c)
	if lista.count(lista[0]) == len(lista):
		print(0)
	else:
		for k in range(0, len(lista)):
			del lista[k]
			p = ''.join(lista)
			if p != p[::-1]:
				break
		print(len(lista))
else:
	print(len(s))


a = input()
t = a[::-1]
c = 0
if a == t:
	x = t[1:]
	t = x[::-1]
	if x == t:
		print(0)
	else:
		print(len(a) - 1)
else:
	print(len(a))


s = input()
n = len(s)
if n == 1:
	print(0)
else:
	ok = 0
	for i in range(n):
		if i != n - 1 - i:
			if s[i] != s[n - 1 - i]:
				ok = 1
				break
	if ok:
		print(n)
	else:
		st = {'2'}
		st.pop()
		for i in range(n):
			st.add(s[i])
		if len(st) == 1:
			print(0)
		else:
			print(n - 1)


s = str(input())
x = set(s)
if len(x) == 1:
	print(0)
elif len(s) == len(x):
	print(len(s))
else:
	i = 0
	if s == s[::-1]:
		while s == s[::-1]:
			s = s[1:]
	print(len(s))


s = input()
n = len(s)
for i in range(n - 1):
	for j in range(i + 1):
		if s[:(n - i) // 2] != s[n - i - 1:n - i - (n - i) // 2 - 1:-1]:
			print(n - i)
			quit()
print(0)


s = input()
s.lower()
y = len(s)
c = []
b = []
for i in range(0, y):
	c.append(s[i])
for j in range(y - 1, -1, -1):
	b.append(s[j])
if b == c:
	count = 0
	for k in range(1, y):
		if s[0] == s[k]:
			count = count + 1
	if count == y - 1:
		print(0)
	elif b == c:
		s = s.replace(s[y - 1], '', 1)
		x = len(s)
		print(x)
else:
	print(y)


def ispal(s):
	rev = ''.join(reversed(s))
	if s == rev:
		return True
	return False
t = input()
if ispal(t) == False:
	print(len(t))
elif t.count(t[0]) == len(t):
	print(0)
else:
	print(len(t) - 1)


def getIntList():
	return list(map(int, input().split()))

def getTransIntList(n):
	first = getIntList()
	m = len(first)
	result = [[0] * n for _ in range(m)]
	for i in range(m):
		result[i][0] = first[i]
	for j in range(1, n):
		curr = getIntList()
		for i in range(m):
			result[i][j] = curr[i]
	return result
s = input()

def solve(s):
	if s != s[::-1]:
		return len(s)
	l = s[0]
	for i in range(len(s)):
		if s[i] != l:
			return len(s) - 1
	return 0
print(solve(s))


def palindrom(word):
	if len(word) % 2 == 0:
		a = word[:len(word) // 2]
		loc = list(word)
		b = loc[len(loc) // 2:]
		b.reverse()
		b = ''.join(b)
		if a == b:
			return True
		else:
			return False
	else:
		a = word[:len(word) // 2 + 1]
		loc = list(word)
		b = loc[len(loc) // 2:]
		b.reverse()
		b = ''.join(b)
		if a == b:
			return True
		else:
			return False

def notpalindrom(word):
	max_substring = 0
	for i in range(1, len(word)):
		if palindrom(word[:i]) == False and len(word[:i]) > max_substring:
			max_substring = len(word[:i])
	for i in range(len(word) - 2, 0, -1):
		if palindrom(word[i:]) == False and len(word[i:]) > max_substring:
			max_substring = len(word[i:])
	if max_substring != 0:
		return max_substring
	else:
		return None
word = input()
if palindrom(word) == False:
	print(len(word))
elif notpalindrom(word) != None:
	print(notpalindrom(word))
else:
	print(0)


def main():
	string = input()
	l = len(string)
	while l > 0:
		palin = string[::-1]
		if palin != string:
			print(len(string))
			break
		string = string[1:]
		l -= 1
	if l is 0:
		print(0)
main()


def isPalindrome(word):
	return word[::-1] == word
fullWord = input()
maxNonPalindrome = 0
if not isPalindrome(fullWord):
	print(len(fullWord))
	exit()
if not isPalindrome(fullWord[0:len(fullWord) - 1]):
	print(len(fullWord) - 1)
	exit()
print(0)


a = input()
b = sorted(a, reverse=False)
if b[0] == b[-1]:
	print('0')
elif a == a[::-1]:
	print(len(a) - 1)
else:
	print(len(a))


def isPalindrome(s):
	for i in range(len(s) // 2):
		if s[i] != s[-(i + 1)]:
			return False
	return True
s = input()
while isPalindrome(s) and s != '':
	s = s[:len(s) - 1]
print(len(s))


s = input()
for i in range(len(s)):
	for j in range(len(s), -1, -1):
		sl = s[i:j]
		sr = sl[::-1]
		if sl != sr:
			print(len(sl))
			exit(0)
print(0)


x = input()
a = x[-1:-len(x) - 1:-1]
if x == x[0] * len(x):
	print(0)
elif x != a:
	print(len(x))
else:
	while 1:
		i = 1
		i = int(i)
		x = x[0:len(x) - i]
		a = x[-1:-len(x) - 1:-1]
		i = i + 1
		if x != a:
			break
	print(len(x))


def main():
	string = input()
	n_chars = len(list(dict.fromkeys([c for c in string])))
	if n_chars == 1:
		print(0)
	elif string == string[::-1]:
		print(len(string) - 1)
	else:
		print(len(string))
main()


s = list(input())
c = len(s)
if s == s[::-1]:
	if len(sorted(set(s))) == 1:
		print('0')
	else:
		while s == s[::-1]:
			s.remove(s[0])
			c -= 1
		print(c)
else:
	print(len(s))


n = input()
x = n[::-1]
flag = 0
for i in range(1, len(n)):
	if n[i] != n[i - 1]:
		flag = 1
if n != x:
	print(len(n))
elif flag == 1:
	print(len(n) - 1)
else:
	print(0)


def is_palindrome(s):
	for i in range(len(s) // 2):
		if s[i] != s[~i]:
			return False
	return True

def max_anti(s, visited):
	if len(s) <= 1:
		return 0
	ts = tuple(s)
	if ts in visited:
		return 0
	visited.add(ts)
	if is_palindrome(s):
		return max(max_anti(s[1:], visited), max_anti(s[:-1], visited))
	return len(s)

def solve(s):
	if len(set(s)) <= 1:
		return 0
	visited = set()
	return max_anti([x for x in s], visited)

def main():
	s = input().strip()
	result = solve(s)
	print(result)
main()