import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.next(); W sc.next() sc.next sc String T; T int count = 0; count 0 ArrayList<String> lowerT = new ArrayList<String>(); lowerT new ArrayList<String>() while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		} true {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		} 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; lowerT.add(T.toLowerCase()) lowerT.add lowerT T.toLowerCase() T.toLowerCase T for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < lowerT.size() i lowerT.size() lowerT.size lowerT i++ i++ i {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		} {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		} if (W.equals(lowerT.get(i))) {
				count++;
			} W.equals(lowerT.get(i)) W.equals W lowerT.get(i) lowerT.get lowerT i {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		;
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}
