use std::io::{Read, stdin}; use std::collections::HashMap; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut tok = buf.split_whitespace(); let mut get = || tok.next().unwrap(); macro_rules! get { ($t:ty) => (get().parse::<$t>().unwrap()); () => (get!(i64)); } let n = get!(); let mut map = HashMap::new(); for _ in 0..n { let s = get!(String); let &c = map.get(&s).unwrap_or(&0); map.insert(s, c+1); } let mut freq = 0; let mut ans = 0; for (s, &c) in map.iter() { if c > freq { freq = c; ans = s.len(); } else if c == freq && s.len() > ans { ans = s.len(); } } ans -= 2; println!("{}", ans); }