/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A&lang=jp
  * String - Finding a Word
  */
object Main {
  def main(args: Array[String]): Unit = {
    val word = io.StdIn.readLine().toLowerCase
    val words = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null)
      .takeWhile(_ != "END_OF_TEXT")
      .flatMap(_.toLowerCase.split("[ \\n]"))
    println(words.count(_ == word))
  }
}