const val EOF = "END_OF_TEXT"

fun main(args: Array<String>) {
    val target = readLine() ?: return
    var count = 0
    while (true) {
        val texts = readLine()?.split(" ")?.map { if(!it.equals(EOF))it.toLowerCase() else it } ?: break
        texts.forEach{
            if(it.equals(target)) count++
        }
        if(texts.contains(EOF)) break
    }
    println(count)
}
