import scala.io.StdIn.readLine

object Main extends App {
  val w = readLine

  var ans = 0
  while (true) {
    val line = readLine
    if (line == "END_OF_TEXT") {
      println(ans); sys.exit
    }
    val words = line.toLowerCase.split(" ")
    ans += words.count(e => e == w)
  }
}
