import scala.io.StdIn.readLine

object Main extends App {
  val w = readLine.trim
  var line = ""
  var cnt = 0

  while( { line = readLine.trim;line } != "END_OF_TEXT") {
      line.split(" ").foreach( t => if(w.equalsIgnoreCase(t)) cnt += 1 )
  }
  println(cnt)
}