
import scala.util.control.Breaks
object Main extends App {
  val pat = readLine

  var cnt = 0

  val b = new Breaks
  b.breakable {
    while (true) {
      val line = readLine

      if (line == "END_OF_TEXT") {
        b.break()
      } else {
        cnt += line.toLowerCase.split(' ').count(_ == pat)
      }
    }
  }
  println(cnt)
}
