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