import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val W = scanner.nextLine()
    var count = 0
    while(scanner.hasNextLine()) {
        val line = scanner.nextLine()
        if (line == "END_OF_TEXT") break
        count += line.split(" ")
            .count { w -> w.toLowerCase() == W.toLowerCase() }
    }
    println(count)
}
