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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String word; word int count = 0; count 0 word = in.readLine() word in.readLine() in.readLine in while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		} true {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		} String[] text; text text = in.readLine().split(" ") text in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " if (text[0].equals("END_OF_TEXT")) {
				break;
			} text[0].equals("END_OF_TEXT") text[0].equals text[0] text 0 "END_OF_TEXT" {
				break;
			} break; for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			} String str text {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			} {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			} str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str if (str.matches(word)) {
					count++;
				} else {
					continue;
				} str.matches(word) str.matches str word {
					count++;
				} count++ count {
					continue;
				} continue; 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 in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String word;
		int count = 0;
		word = in.readLine();
		while (true) {
			String[] text;
			text = in.readLine().split(" ");
			if (text[0].equals("END_OF_TEXT")) {
				break;
			}
			for (String str : text) {
				str = str.toLowerCase();
				if (str.matches(word)) {
					count++;
				} else {
					continue;
				}
			}
		}
		System.out.println(count);
	}
}