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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> lisT = new ArrayList<String>();
	public static void main(String[] args) {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	}

	private static void findingAword(String W, String[] T) {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	}



	private static String[] inpStr() {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	}

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

	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> lisT = new ArrayList<String>();
	public static void main(String[] args) {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	}

	private static void findingAword(String W, String[] T) {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	}



	private static String[] inpStr() {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	}

} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static ArrayList<String> lisT = new ArrayList<String>(); lisT new ArrayList<String>() public static void main(String[] args) {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	} main {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	} String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc String[] T = inpStr(); T inpStr() inpStr findingAword(W, T) findingAword W T sc.close() sc.close sc String[] args args private static void findingAword(String W, String[] T) {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	} findingAword {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	} int wd = 0; wd 0 for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		} int i = 0; int i = 0; i 0 i < T.length i T.length T T.length i++ i++ i {
			if( T[i].equals(W) ) {
				wd++;
			}
		} {
			if( T[i].equals(W) ) {
				wd++;
			}
		} if( T[i].equals(W) ) {
				wd++;
			} T[i].equals(W) T[i].equals T[i] T i W {
				wd++;
			} wd++ wd System.out.println(wd) System.out.println System.out System System.out wd String W W String[] T T private static String[] inpStr() {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	} inpStr {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	} while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		} sc.hasNextLine() sc.hasNextLine sc {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		} String t = " " + sc.nextLine() + " "; t " " + sc.nextLine() + " " " " + sc.nextLine() + " " " " sc.nextLine() sc.nextLine sc " " if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			} t.equals(" END_OF_TEXT ") t.equals t " END_OF_TEXT " {
				break;
			} break; {
				lisT.add(t);
			} lisT.add(t) lisT.add lisT t String str = lisT.toString(); str lisT.toString() lisT.toString lisT str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str String[] strs = str.split(" "); strs str.split(" ") str.split str " " return strs; strs public class Main {

	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> lisT = new ArrayList<String>();
	public static void main(String[] args) {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	}

	private static void findingAword(String W, String[] T) {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	}



	private static String[] inpStr() {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	}

} public class Main {

	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> lisT = new ArrayList<String>();
	public static void main(String[] args) {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	}

	private static void findingAword(String W, String[] T) {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	}



	private static String[] inpStr() {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	}

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> lisT = new ArrayList<String>();
	public static void main(String[] args) {

		String W = sc.nextLine();
		String[] T = inpStr();

		findingAword(W, T);
		sc.close();

	}

	private static void findingAword(String W, String[] T) {
		int wd = 0;

		for (int i = 0; i < T.length; i++) {
			if( T[i].equals(W) ) {
				wd++;
			}
		}

		System.out.println(wd);

	}



	private static String[] inpStr() {
		while (sc.hasNextLine()) {
			String t = " " + sc.nextLine() + " ";

			if (t.equals(" END_OF_TEXT ")) {
				break;
			} else {
				lisT.add(t);
			}

		}
		String str = lisT.toString();

		str = str.toLowerCase();


		String[] strs = str.split(" ");

		return strs;
	}

}
