import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

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

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	} main {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	} String W = input().toLowerCase(); W input().toLowerCase() input().toLowerCase input() input String T; T int count = 0; count 0 while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		} !(T = input()).equals("END_OF_TEXT") (T = input()).equals("END_OF_TEXT") (T = input()).equals (T = input()) T input() input "END_OF_TEXT" {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		} String[] TArrays = T.split(" "); TArrays T.split(" ") T.split T " " for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			} int i = 0; int i = 0; i 0 i < TArrays.length i TArrays.length TArrays TArrays.length i++ i++ i {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			} {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			} if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				} TArrays[i].equalsIgnoreCase(W) TArrays[i].equalsIgnoreCase TArrays[i] TArrays i W {

					count++;

				} count++ count System.out.println(count) System.out.println System.out System System.out count close() close String[] args args public static String input() {

		return scanner.nextLine();

	} input {

		return scanner.nextLine();

	} return scanner.nextLine(); scanner.nextLine() scanner.nextLine scanner public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	} close {

		if (scanner != null) {

			scanner.close();

		}
	} if (scanner != null) {

			scanner.close();

		} scanner != null scanner null {

			scanner.close();

		} scanner.close() scanner.close scanner public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String W = input().toLowerCase();
		String T;
		int count = 0;

		while (!(T = input()).equals("END_OF_TEXT")) {

			String[] TArrays = T.split(" ");

			for (int i = 0; i < TArrays.length; i++) {

				if (TArrays[i].equalsIgnoreCase(W)) {

					count++;

				}
			}
		}

		System.out.println(count);

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}