import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
    	String s,w;int ans=0; 
    	w=sc.nextLine().toLowerCase();
    	for(;;){
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
}
System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
    	String s,w;int ans=0; 
    	w=sc.nextLine().toLowerCase();
    	for(;;){
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
}
System.out.println(ans);
    }
} Main public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
    	String s,w;int ans=0; 
    	w=sc.nextLine().toLowerCase();
    	for(;;){
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
}
System.out.println(ans);
    } main {
    	Scanner sc= new Scanner(System.in);
    	String s,w;int ans=0; 
    	w=sc.nextLine().toLowerCase();
    	for(;;){
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
}
System.out.println(ans);
    } Scanner sc= new Scanner(System.in); sc new Scanner(System.in) String s s w; w int ans=0; ans 0 w=sc.nextLine().toLowerCase() w sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc for(;;){
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
} ; {
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
} {
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
} s=sc.next() s sc.next() sc.next sc if(s.equals("END_OF_TEXT")) break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; s=s.toLowerCase() s s.toLowerCase() s.toLowerCase s if(w.equals(s)) ans++; w.equals(s) w.equals w s ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
    	String s,w;int ans=0; 
    	w=sc.nextLine().toLowerCase();
    	for(;;){
    		s=sc.next();if(s.equals("END_OF_TEXT")) break; 
    		s=s.toLowerCase();
    		if(w.equals(s)) ans++;
}
System.out.println(ans);
    }
}