import scala.io.StdIn

object Main extends App {

  private val w = StdIn.readLine()
  val wsize = w.length
  var text = ""
  var cnt = 0
  
  do {
    cnt += text.toLowerCase.split(' ').count(p => p == w)
    text = StdIn.readLine()
  } while(text != "END_OF_TEXT")
  
  println(cnt)
  
}
