import scala.io.Source.stdin
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    val w = StdIn.readLine()

    var count = 0
    for(line <- stdin.getLines()){
      if(line == "END_OF_TEXT"){
        println(count)
        return
      }
      for(word <- line.toLowerCase.split(" ")){
        if(w == word){count += 1}
      }
    }
  }
}