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

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

		Scanner scanner = new Scanner(System.in);
		String ans = scanner.nextLine().toLowerCase();
		int count = 0;
		
		end:
		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			String[] strs = str.split(" ");
			for (int i = 0; i < strs.length; i++) {
				if(strs[i].equals("END_OF_TEXT")){
					break end;
				}
				if (strs[i].toLowerCase().equals(ans)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);
		String ans = scanner.nextLine().toLowerCase();
		int count = 0;
		
		end:
		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			String[] strs = str.split(" ");
			for (int i = 0; i < strs.length; i++) {
				if(strs[i].equals("END_OF_TEXT")){
					break end;
				}
				if (strs[i].toLowerCase().equals(ans)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);
		String ans = scanner.nextLine().toLowerCase();
		int count = 0;
		
		end:
		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			String[] strs = str.split(" ");
			for (int i = 0; i < strs.length; i++) {
				if(strs[i].equals("END_OF_TEXT")){
					break end;
				}
				if (strs[i].toLowerCase().equals(ans)) {
					count++;
				}
			}
		}
		System.out.println(count);
	} main {

		Scanner scanner = new Scanner(System.in);
		String ans = scanner.nextLine().toLowerCase();
		int count = 0;
		
		end:
		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			String[] strs = str.split(" ");
			for (int i = 0; i < strs.length; i++) {
				if(strs[i].equals("END_OF_TEXT")){
					break end;
				}
				if (strs[i].toLowerCase().equals(ans)) {
					count++;
				}
			}
		}
		System.out.println(count);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String ans = scanner.nextLine().toLowerCase(); ans scanner.nextLine().toLowerCase() scanner.nextLine().toLowerCase scanner.nextLine() scanner.nextLine scanner int count = 0; count 0 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.IOException;
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);
		String ans = scanner.nextLine().toLowerCase();
		int count = 0;
		
		end:
		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			String[] strs = str.split(" ");
			for (int i = 0; i < strs.length; i++) {
				if(strs[i].equals("END_OF_TEXT")){
					break end;
				}
				if (strs[i].toLowerCase().equals(ans)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}