import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.next().toLowerCase();
		String T = new String();
		int cnt = 0;
		while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.next().toLowerCase();
		String T = new String();
		int cnt = 0;
		while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.next().toLowerCase();
		String T = new String();
		int cnt = 0;
		while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		Scanner in = new Scanner(System.in);
		String W = in.next().toLowerCase();
		String T = new String();
		int cnt = 0;
		while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String W = in.next().toLowerCase(); W in.next().toLowerCase() in.next().toLowerCase in.next() in.next in String T = new String(); T new String() int cnt = 0; cnt 0 while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		} !in.hasNext("END_OF_TEXT") in.hasNext("END_OF_TEXT") in.hasNext in "END_OF_TEXT" {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		} T = in.next().toLowerCase() T in.next().toLowerCase() in.next().toLowerCase in.next() in.next in if (T.matches(W)) {
				cnt++;
			} T.matches(W) T.matches T W {
				cnt++;
			} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.next().toLowerCase();
		String T = new String();
		int cnt = 0;
		while (!in.hasNext("END_OF_TEXT")) {
			T = in.next().toLowerCase();
			if (T.matches(W)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}