import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String w = input.readLine();
		String t;
		int num = 0;

		while (!(t = input.readLine()).equals("END_OF_TEXT")) {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		}

		System.out.println(num);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String w = input.readLine();
		String t;
		int num = 0;

		while (!(t = input.readLine()).equals("END_OF_TEXT")) {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		}

		System.out.println(num);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String w = input.readLine();
		String t;
		int num = 0;

		while (!(t = input.readLine()).equals("END_OF_TEXT")) {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		}

		System.out.println(num);
	} main {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String w = input.readLine();
		String t;
		int num = 0;

		while (!(t = input.readLine()).equals("END_OF_TEXT")) {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		}

		System.out.println(num);
	} BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) String w = input.readLine(); w input.readLine() input.readLine input String t; t int num = 0; num 0 while (!(t = input.readLine()).equals("END_OF_TEXT")) {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		} !(t = input.readLine()).equals("END_OF_TEXT") (t = input.readLine()).equals("END_OF_TEXT") (t = input.readLine()).equals (t = input.readLine()) t input.readLine() input.readLine input "END_OF_TEXT" {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		} t = t.toLowerCase() t t.toLowerCase() t.toLowerCase t Scanner scan = new Scanner(t); scan new Scanner(t) while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			} scan.hasNext() scan.hasNext scan {
				String str = scan.next();
				if (str.equals(w))
					num++;
			} String str = scan.next(); str scan.next() scan.next scan if (str.equals(w))
					num++; str.equals(w) str.equals str w num++ num System.out.println(num) System.out.println System.out System System.out num String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String w = input.readLine();
		String t;
		int num = 0;

		while (!(t = input.readLine()).equals("END_OF_TEXT")) {
			t = t.toLowerCase();
			Scanner scan = new Scanner(t);
			while (scan.hasNext()) {
				String str = scan.next();
				if (str.equals(w))
					num++;
			}

		}

		System.out.println(num);
	}
}