import scala.io.StdIn

object Main extends App {
  val pattern = StdIn.readLine().toString.map(_.toLower)
  var text = ""
  var line = ""
  while (line != "END_OF_TEXT") {
    line = StdIn.readLine().toString
    text += line
  }
  val matchCount = pattern.r.findAllIn(text.map(_.toLower)).matchData.map(_.start).toList.length
  println(matchCount)
}