import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)
    var count:Int = 0
    val w = cin.next()
    
    while(true){
	    var s = cin.next()
	    if(s == "END_OF_TEXT") break
    	s = s.toLowerCase()
	    if(s == w){
	    count++ 
	}
	
    }
    println(count)

}
