import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	} main {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine(); w sc.nextLine() sc.nextLine sc int result = 0; result 0 while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		} true {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		} String t1 = sc.nextLine(); t1 sc.nextLine() sc.nextLine sc if ("END_OF_TEXT".equals(t1)) {
				break;
			} "END_OF_TEXT".equals(t1) "END_OF_TEXT".equals "END_OF_TEXT" t1 {
				break;
			} break; t1 = t1.toLowerCase() t1 t1.toLowerCase() t1.toLowerCase t1 String[] arr = t1.split(" "); arr t1.split(" ") t1.split t1 " " for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			} int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
				if (w.equals(arr[i])) {
					result++;
				}
			} {
				if (w.equals(arr[i])) {
					result++;
				}
			} if (w.equals(arr[i])) {
					result++;
				} w.equals(arr[i]) w.equals w arr[i] arr i {
					result++;
				} result++ result System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	}
}
