import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	}
} Main public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	} main {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<String> klist = new ArrayList<String>(); klist new ArrayList<String>() String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		} true {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		} String line2 = sc.nextLine(); line2 sc.nextLine() sc.nextLine sc klist.add(line2) klist.add klist line2 if (line2.equals("END_OF_TEXT")) {
				break;
			} line2.equals("END_OF_TEXT") line2.equals line2 "END_OF_TEXT" {
				break;
			} break; int count = 0; count 0 for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		} String string klist {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		} {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		} String[] k = string.split(" "); k string.split(" ") string.split string " " for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			} int j = 0; int j = 0; j 0 j < k.length j k.length k k.length j++ j++ j {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			} {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			} if (k[j].equalsIgnoreCase(line)) {
					count++;
				} k[j].equalsIgnoreCase(line) k[j].equalsIgnoreCase k[j] k j line {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count String[] arges arges public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	}
} public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> klist = new ArrayList<String>();
		String line = sc.nextLine();
		while (true) {
			String line2 = sc.nextLine();
			klist.add(line2);
			if (line2.equals("END_OF_TEXT")) {
				break;
			}
		}
		int count = 0;
		for (String string : klist) {
			String[] k = string.split(" ");

			for (int j = 0; j < k.length; j++) {
				if (k[j].equalsIgnoreCase(line)) {
					count++;
				}
			}
		}
		System.out.println(count);

	}
}