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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	} main {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String w = scan.nextLine().toLowerCase(); w scan.nextLine().toLowerCase() scan.nextLine().toLowerCase scan.nextLine() scan.nextLine scan int count = 0; count 0 while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		} true {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		} String t = scan.next(); t scan.next() scan.next scan if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++; t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" break; if (t.toLowerCase().equals(w)) count++; t.toLowerCase().equals(w) t.toLowerCase().equals t.toLowerCase() t.toLowerCase t w count++ count scan.close() scan.close scan 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) throws IOException {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	}
} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine().toLowerCase();
		int count = 0;
		while (true) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT")) break;
			else if (t.toLowerCase().equals(w)) count++;
		}
		scan.close();
		System.out.println(count);
	}
}