
object Main extends App{
  override def main(args : Array[String]) : Unit = {
    val w = readLine
    
    val result = io.Source.stdin.getLines.filter(line=>line!="END_OF_TEXT").map(line=>
        line.split(' ').filter(word => w.equalsIgnoreCase(word)).size).reduce((z,n)=>z+n)

    println(result)
  }

}