import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	}
} 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()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = (sc.nextLine()).toUpperCase(); W (sc.nextLine()).toUpperCase() (sc.nextLine()).toUpperCase (sc.nextLine()) sc.nextLine sc String T = ""; T "" int count = 0; count 0 while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		} true {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		} T = sc.nextLine() T sc.nextLine() sc.nextLine sc if (T.equals("END_OF_TEXT")) {
				break;
			} T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
				break;
			} break; String[] str = T.split(" ", -1); str T.split(" ", -1) T.split T " " -1 1 for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					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(W)) {
					count++;
				}
			} {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			} if ((str[i].toUpperCase()).equals(W)) {
					count++;
				} (str[i].toUpperCase()).equals(W) (str[i].toUpperCase()).equals (str[i].toUpperCase()) str[i].toUpperCase str[i] str i W {
					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) {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = (sc.nextLine()).toUpperCase();

		String T = "";
		int count = 0;
		while (true) {
			T = sc.nextLine();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			String[] str = T.split(" ", -1);
			for (int i = 0; i < str.length; i++) {
				if ((str[i].toUpperCase()).equals(W)) {
					count++;
				}
			}

		}
		System.out.println(count);
	}
}