//9-A
 
import java.util.Scanner;
 
class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
         
        String W = sc.next();//??????
        
        int count = 0;
        
        while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        }
        
         System.out.println(count);
        
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
         
        String W = sc.next();//??????
        
        int count = 0;
        
        while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        }
        
         System.out.println(count);
        
    }
} Main public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
         
        String W = sc.next();//??????
        
        int count = 0;
        
        while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        }
        
         System.out.println(count);
        
    } main {
         
        Scanner sc = new Scanner(System.in);
         
        String W = sc.next();//??????
        
        int count = 0;
        
        while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        }
        
         System.out.println(count);
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.next(); W sc.next() sc.next sc int count = 0; count 0 while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        } true {
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        } String T = sc.next(); T sc.next() sc.next sc if(T.equals("END_OF_TEXT")){
        		break;
        	} T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
        		break;
        	} break; String[] str = T.split(" "); str T.split(" ") T.split T " " for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	} {
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	} if(str[i].equalsIgnoreCase(W)){
        			count++;
        		} str[i].equalsIgnoreCase(W) str[i].equalsIgnoreCase str[i] str i W {
        			count++;
        		} count++ count System.out.println(count) System.out.println System.out System System.out count String [] args args
//9-A
 
import java.util.Scanner;
 
class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
         
        String W = sc.next();//??????
        
        int count = 0;
        
        while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        }
        
         System.out.println(count);
        
    }
}