object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.toList.init
        println(in.tail.map(_.split(" ").count(_.toUpperCase == in.head.toUpperCase)).sum)
    }
}