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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc W = W.toLowerCase() W W.toLowerCase() W.toLowerCase W ArrayList<String> T = new ArrayList<String>(); T new ArrayList<String>() String kari = ""; kari "" int ts = 0; ts 0 while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		} true {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		} kari = sc.nextLine() kari sc.nextLine() sc.nextLine sc if (kari.equals("END_OF_TEXT")) {
				break;
			} kari.equals("END_OF_TEXT") kari.equals kari "END_OF_TEXT" {
				break;
			} break; T.add(kari.toLowerCase()) T.add T kari.toLowerCase() kari.toLowerCase kari ts++ ts int answer = 0; answer 0 for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		} int i = 0; int i = 0; i 0 i < ts i ts i++ i++ i {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		} {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		} String[] str = T.get(i).split(" "); str T.get(i).split(" ") T.get(i).split T.get(i) T.get T i " " for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			} int j = 0; int j = 0; j 0 j < str.length j str.length str str.length j++ j++ j {
				if (str[j].equals(W)) {
					answer++;
				}
			} {
				if (str[j].equals(W)) {
					answer++;
				}
			} if (str[j].equals(W)) {
					answer++;
				} str[j].equals(W) str[j].equals str[j] str j W {
					answer++;
				} answer++ answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	}

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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();

		ArrayList<String> T = new ArrayList<String>();
		String kari = "";
		int ts = 0;

		while (true) {
			kari = sc.nextLine();
			if (kari.equals("END_OF_TEXT")) {
				break;
			}
			T.add(kari.toLowerCase());
			ts++;
		}

		int answer = 0;

		for (int i = 0; i < ts; i++) {
			
			String[] str = T.get(i).split(" ");
			for (int j = 0; j < str.length; j++) {
				if (str[j].equals(W)) {
					answer++;
				}
			}

		}
		
		System.out.println(answer);
	}

}