fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn main() { let s: String = read(); let t: String = read(); println!("{}", no1005(s,t)); } fn no1005(s: String, t: String) -> i32 { if t.len() == 1 && s.contains(t.chars().next().unwrap()) { -1 } else if t.len() > s.len() { 0 } else { let mut result = None; let mut idx = 0; let max = s.len() - t.len() + 1; loop { let sub = format!("{}", &s.as_str()[idx..idx+t.len()]); if sub == t { result = match result { None => Some(1), Some(v) => Some(v+1), }; idx = idx + t.len() - 1; } else { idx = idx + 1; } if idx >= max { break; } } result.unwrap_or(0) } }