import scala.io.StdIn._

object Main {
  def mkInputText(i: Iterator[String]): List[String] = {
    (for(j <- i if j != "END_OF_TEXT") yield j.replace("\n", "")).mkString(" ").split(" ").toList
  }

  def main(args: Array[String]) {
    val searchText = readLine()
    val inputTextList = mkInputText(scala.io.Source.stdin.getLines)
    println(inputTextList.count(_ == searchText))
  }
}