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
        val w = in.next
        val ans = (for (s <- in if s != "END_OF_TEXT") yield sub(w, s)).sum
        println(ans)
    }
}