import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.next(); W sc.next() sc.next sc int count =0; count 0 while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		} true {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		} String t = sc.next(); t sc.next() sc.next sc if (t.equals("END_OF_TEXT")) {
				break;
			} t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" {
				break;
			} break; t = t.toLowerCase() t t.toLowerCase() t.toLowerCase t t = t.replace(".", "") t t.replace(".", "") t.replace t "." "" if (t.equals(W)) {
				count++;
			} t.equals(W) t.equals t W {
				count++;
			} count++ count 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) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	}

}