

object Main extends App {
  override def main(args: Array[String]): Unit = {
    val w = io.StdIn.readLine

    val res = io.Source.stdin.getLines.takeWhile(_ != "END_OF_TEXT").
      foldLeft(0)((z, str) => {
        z + str.split(' ').count(_.equalsIgnoreCase(w))
      })

    println(res)
  }
}