object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    val w = scanner.next.toLowerCase()
    var c = 0
    while(true) {
      val t = scanner.next.toLowerCase()
      if(t.equals("end_of_text")) {
        println(c)
        System.exit(0)
      }
      if(w.equals(t)) c = c + 1
    }
  }
}

