fun main(args: Array<String>) {
    val word = readLine()!!
    var numCount = 0
    while (true) {
        val sentence = readLine()!!
        if (sentence == "END_OF_TEXT") break
        sentence.toLowerCase().split(" ").forEach { if (word == it) numCount++ }
    }
    println("$numCount")
}

