use std::{ collections::{BTreeSet, HashMap}, hash::Hash, }; fn main() { proconio::input! { s: String, } let mut cww_max = i64::MAX; let s = s.chars().collect::>(); for (i_c, _) in s.iter().copied().enumerate().filter(|c| c.1 == 'c') { if let Some((i_w1, _)) = s .iter() .copied() .enumerate() .skip(i_c + 1) .find(|c| c.1 == 'w') { if let Some((i_w2, _)) = s .iter() .copied() .enumerate() .skip(i_w1 + 1) .find(|c| c.1 == 'w') { cww_max = std::cmp::min(cww_max, (i_w2 - i_c) as i64 + 1); } } } println!("{}", if cww_max == i64::MAX { -1 } else { cww_max }); }