use std::cmp::{max, min}; fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s: Vec = s.trim().chars().collect(); let mut maxlen: usize = 1; for i in 0..s.len() { let mut temp: usize = 1; //odd for j in 0..min(s.len()-i-1, i) { if s[i - j - 1] == s[i + j + 1] { temp += 2; } else { break; } } maxlen = max(maxlen, temp); if i == 0 { continue; } let mut temp2: usize = 0; //even for j in 1..=min(s.len()-i, i) { if s[i - j] == s[i + j - 1] { temp2 += 2; } else { break; } } maxlen = max(maxlen, temp2); } if maxlen == s.len() { if s.iter().skip(1).map(|c| (*c).to_string()).collect::>().join("") == s.iter().skip(1).rev().map(|c| (*c).to_string()).collect::>().join("") || s.iter().take(s.len()-1).map(|c| (*c).to_string()).collect::>().join("") == s.iter().rev().skip(1).map(|c| (*c).to_string()).collect::>().join("") { println!("{}", s.len() - 1); } else { println!("{}", s.len() - 2); } } else { println!("{}", maxlen); } }