import java.util.Scanner;
class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String W;
    	String T;
    	String change_W = "";
    	String change_T = "" ;
    	String end = "END_OF_TEXT";
    	int count = 0;
    	
    	W = scan.nextLine();
    	change_W = W.toLowerCase();
    	
    	for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	}
    	
    	 System.out.println(count);
     }
} import java.util.Scanner; Scanner java.util class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String W;
    	String T;
    	String change_W = "";
    	String change_T = "" ;
    	String end = "END_OF_TEXT";
    	int count = 0;
    	
    	W = scan.nextLine();
    	change_W = W.toLowerCase();
    	
    	for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	}
    	
    	 System.out.println(count);
     }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String W;
    	String T;
    	String change_W = "";
    	String change_T = "" ;
    	String end = "END_OF_TEXT";
    	int count = 0;
    	
    	W = scan.nextLine();
    	change_W = W.toLowerCase();
    	
    	for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	}
    	
    	 System.out.println(count);
     } main {
    	Scanner scan = new Scanner(System.in);
    	String W;
    	String T;
    	String change_W = "";
    	String change_T = "" ;
    	String end = "END_OF_TEXT";
    	int count = 0;
    	
    	W = scan.nextLine();
    	change_W = W.toLowerCase();
    	
    	for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	}
    	
    	 System.out.println(count);
     } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W; W String T; T String change_W = ""; change_W "" String change_T = "" ; change_T "" String end = "END_OF_TEXT"; end "END_OF_TEXT" int count = 0; count 0 W = scan.nextLine() W scan.nextLine() scan.nextLine scan change_W = W.toLowerCase() change_W W.toLowerCase() W.toLowerCase W for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	} ; {
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	} {
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	} T = scan.nextLine() T scan.nextLine() scan.nextLine scan if(T.equals(end)) break; T.equals(end) T.equals T end break; change_T = T.toLowerCase() change_T T.toLowerCase() T.toLowerCase T String sepa[] = change_T.split(" "); sepa change_T.split(" ") change_T.split change_T " " for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		} int i = 0; int i = 0; i 0 i < sepa.length i sepa.length sepa sepa.length i++ i++ i {
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		} {
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		} if(change_W.equals(sepa[i])){
    				count++;
    			} change_W.equals(sepa[i]) change_W.equals change_W sepa[i] sepa i {
    				count++;
    			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.Scanner;
class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String W;
    	String T;
    	String change_W = "";
    	String change_T = "" ;
    	String end = "END_OF_TEXT";
    	int count = 0;
    	
    	W = scan.nextLine();
    	change_W = W.toLowerCase();
    	
    	for(;;){
        	T = scan.nextLine();
    		if(T.equals(end)) break;  		
    		change_T = T.toLowerCase();
    		String sepa[] = change_T.split(" ");
    		
    		for(int i = 0; i < sepa.length; i++){
    			if(change_W.equals(sepa[i])){
    				count++;
    			}
    		}
    		
    	}
    	
    	 System.out.println(count);
     }
}