object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val w = scanner.next().toLowerCase

  val inputs = Iterator.continually(scanner.next())
    .map(_.toLowerCase)
    .takeWhile(_ != "END_OF_TEXT")

  val output = inputs.count(_ == w)

  println(output)
}