import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
					
		String str, str2;
		
		str = br.readLine();
		str = str.toLowerCase();

		int sum = 0;
		
		while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		}
		System.out.println(sum);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
					
		String str, str2;
		
		str = br.readLine();
		str = str.toLowerCase();

		int sum = 0;
		
		while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		}
		System.out.println(sum);
	}
} Main public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
					
		String str, str2;
		
		str = br.readLine();
		str = str.toLowerCase();

		int sum = 0;
		
		while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		}
		System.out.println(sum);
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
					
		String str, str2;
		
		str = br.readLine();
		str = str.toLowerCase();

		int sum = 0;
		
		while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		}
		System.out.println(sum);
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) String str str str2; str2 str = br.readLine() str br.readLine() br.readLine br str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str int sum = 0; sum 0 while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		} true {
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		} str2 = br.readLine() str2 br.readLine() br.readLine br if (str2.equals("END_OF_TEXT")) break; str2.equals("END_OF_TEXT") str2.equals str2 "END_OF_TEXT" break; str2 = str2.toLowerCase() str2 str2.toLowerCase() str2.toLowerCase str2 String st[] = str2.split(" ", 0); st str2.split(" ", 0) str2.split str2 " " 0 for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			} int i = 0; int i = 0; i 0 i < st.length i st.length st st.length i++ i++ i {
				if(st[i].equals(str)){
					sum++;
				}
			} {
				if(st[i].equals(str)){
					sum++;
				}
			} if(st[i].equals(str)){
					sum++;
				} st[i].equals(str) st[i].equals st[i] st i str {
					sum++;
				} sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String args[] args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
					
		String str, str2;
		
		str = br.readLine();
		str = str.toLowerCase();

		int sum = 0;
		
		while(true){
			str2 = br.readLine();	
			if (str2.equals("END_OF_TEXT")) break;
			
			str2 = str2.toLowerCase();
			String st[] = str2.split(" ", 0);
			for(int i = 0; i < st.length; i++){
				if(st[i].equals(str)){
					sum++;
				}
			}
		}
		System.out.println(sum);
	}
}