#![allow(unused_imports)] #![allow(non_snake_case)] use std::collections::HashMap; use std::collections::HashSet; use std::collections::VecDeque; #[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => ((0..$n).map(|_| read!([$t])).collect::>()); ($($t:ty),+ ; $n:expr) => ((0..$n).map(|_| read!($($t),+)).collect::>()); ([$t:ty]) => (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>()); ($t:ty) => (rl().parse::<$t>().unwrap()); ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } #[allow(dead_code)] fn rl() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().to_owned() } fn main() { let s = read!(String); let s: Vec = s.chars().collect(); let mut max = (1, 1); for start in 0..s.len() { for end in start+max.1+1..s.len()+1 { if is_palindrome(&s[start..end]) { max = (max.1, end - start); } } } if max.1 != s.len() { println!("{}", max.1); } else { println!("{}", max.0); } } fn is_palindrome(s: &[char]) -> bool { let mut flg = true; let len = s.len(); for i in 0..len/2 { flg &= s[i] == s[len-1 - i]; } flg }