fun main(args: Array<String>) {
    val w = readLine()!!
    var wNum = 0
    while (true) {
        val list = readLine()!!.split(" ")
        if (list[0] == "END_OF_TEXT") break
        val wList = list.filter { it.toLowerCase() == w }
        wNum += wList.size
    }
    println(wNum)
}
