import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String keyword = br.readLine();
		int cnt=0;
		String str;
		while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String keyword = br.readLine();
		int cnt=0;
		String str;
		while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String keyword = br.readLine();
		int cnt=0;
		String str;
		while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String keyword = br.readLine();
		int cnt=0;
		String str;
		while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String keyword = br.readLine(); keyword br.readLine() br.readLine br int cnt=0; cnt 0 String str; str while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		} (str = br.readLine()) != null (str = br.readLine()) str br.readLine() br.readLine br null {
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		} if(str.equals("END_OF_TEXT")){
				break;
			} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
				break;
			} break; String[] w = str.split(" "); w str.split(" ") str.split str " " for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			} int i=0; int i=0; i 0 i<w.length i w.length w w.length i++ i++ i {
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			} {
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			} if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				} w[i].equalsIgnoreCase(keyword) w[i].equalsIgnoreCase w[i] w i keyword {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] arg arg
import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String keyword = br.readLine();
		int cnt=0;
		String str;
		while((str = br.readLine()) != null){
			if(str.equals("END_OF_TEXT")){
				break;
			}
			String[] w = str.split(" ");
			for(int i=0; i<w.length; i++){
				if(w[i].equalsIgnoreCase(keyword)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}