import java.io.*;


class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String x = br.readLine();
		int count = 0;
		for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		}
		System.out.println(count);
	}

} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String x = br.readLine();
		int count = 0;
		for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String x = br.readLine();
		int count = 0;
		for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		}
		System.out.println(count);
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String x = br.readLine();
		int count = 0;
		for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str String x = br.readLine(); x br.readLine() br.readLine br int count = 0; count 0 for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		} ; !((str = br.readLine()).equals("END_OF_TEXT")) ((str = br.readLine()).equals("END_OF_TEXT")) (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "END_OF_TEXT" {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		} {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		} String[] stg = str.split(" "); stg str.split(" ") str.split str " " for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			} String i stg {
				if (i.equalsIgnoreCase(x))
					count++;
			} {
				if (i.equalsIgnoreCase(x))
					count++;
			} if (i.equalsIgnoreCase(x))
					count++; i.equalsIgnoreCase(x) i.equalsIgnoreCase i x count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.*;


class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String x = br.readLine();
		int count = 0;
		for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		}
		System.out.println(count);
	}

}