
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	} main {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String d = scanner.nextLine(); d scanner.nextLine() scanner.nextLine scanner int sum = 0; sum 0 while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		} true {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		} String a = scanner.nextLine(); a scanner.nextLine() scanner.nextLine scanner if (a.equals("END_OF_TEXT"))
				break; a.equals("END_OF_TEXT") a.equals a "END_OF_TEXT" break; for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			} String s a.split(" ") a.split a " " {
				if (s.equalsIgnoreCase(d))
					sum++;
			} {
				if (s.equalsIgnoreCase(d))
					sum++;
			} if (s.equalsIgnoreCase(d))
					sum++; s.equalsIgnoreCase(d) s.equalsIgnoreCase s d sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String d = scanner.nextLine();
		int sum = 0;
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("END_OF_TEXT"))
				break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					sum++;
			}
		}
		System.out.println(sum);

	}
}