import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		int cnt = 0;
			while(true){
				String[] str = br.readLine().split(" ");
					if(str[0].equals("END_OF_TEXT")){
						break;
					}	
					for(int i = 0;i < str.length; i++){
					if(str[i].equalsIgnoreCase(x)) cnt += 1;	
				}
			}

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

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

		    System.out.println(cnt);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		int cnt = 0;
			while(true){
				String[] str = br.readLine().split(" ");
					if(str[0].equals("END_OF_TEXT")){
						break;
					}	
					for(int i = 0;i < str.length; i++){
					if(str[i].equalsIgnoreCase(x)) cnt += 1;	
				}
			}

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

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

		    System.out.println(cnt);
	}
} Main
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		int cnt = 0;
			while(true){
				String[] str = br.readLine().split(" ");
					if(str[0].equals("END_OF_TEXT")){
						break;
					}	
					for(int i = 0;i < str.length; i++){
					if(str[i].equalsIgnoreCase(x)) cnt += 1;	
				}
			}

		    System.out.println(cnt);
	}
}