object Main {
    def sub(w: String, s: String): Int = {
        if (w.size > s.size) 0
        else if (s startsWith w) 1 + sub(w, s diff w)
        else sub(w, s.tail)
    }
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.toList.init
        println(in.tail.map(s => sub(in.head, s)).sum)
    }
}