use std::{ collections::{BTreeSet, HashMap, HashSet, VecDeque}, fmt::Debug, io::stdin, str::FromStr, sync::OnceLock, }; use proconio::marker::Chars; fn main() { proconio::input! { s: String, m: usize, c: [String; m], } let hash = |s: &[u8]| { s.iter() .enumerate() .map(|(i, &v)| (26u64).pow(i as u32) * (v - b'A') as u64) .fold(0, |a, b| a + b) }; let s = s.as_bytes().into_iter().copied().collect::>(); let hashes = (1..=10) .map(|l| s.windows(l).map(hash).collect::>()) .collect::>(); let count = c .into_iter() .map(|c| { let current = hash(c.as_bytes()); hashes[c.len() - 1] .iter() .filter(|&&h| h == current) .count() }) .sum::(); println!("{count}"); }