#![allow(non_snake_case)] use std::cmp; use std::io::{ self, prelude::* }; macro_rules! pick { ($tokens:expr) => { $tokens.next().unwrap().parse().expect("parse error") } } fn read() -> String { let mut s = String::new(); io::stdin().read_to_string(&mut s).expect("i/o error"); s } fn f_odd(S: &[char]) -> u32 { let mut res = 0; for i in 0..S.len() { let mut cur = 1; for j in 1.. { let l = i as i64 - j as i64; let r = i as i64 + j as i64; if l < 0 || r >= S.len() as i64 { break; } if S[l as usize] == S[r as usize] { cur += 2; } } res = cmp::max(res, cur); } res } fn f_even(S: &[char]) -> u32 { if S.len() < 2 { return 0; } let mut res = 0; for i in 1..S.len() { let mut cur = 0; for j in 0.. { let l = i as i64 - j as i64 - 1; let r = i as i64 + j as i64; if l < 0 || r >= S.len() as i64 { break; } if S[l as usize] == S[r as usize] { cur += 2; } } res = cmp::max(res, cur); } res } fn main() { let s = read(); let mut tokens = s.split_whitespace(); let S: String = pick!(tokens); let S: Vec<_> = S.chars().collect(); let ans = cmp::max(f_odd(&S), f_even(&S)); println!("{}", ans); }