import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String word = br.readLine(); word br.readLine() br.readLine br int cnt = 0; cnt 0 String line; line while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		} (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		} if (line.equals("END_OF_TEXT"))
				break; line.equals("END_OF_TEXT") line.equals line "END_OF_TEXT" break; for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			} String w line.split(" ") line.split line " " {
				if (word.equalsIgnoreCase(w))
					cnt++;
			} {
				if (word.equalsIgnoreCase(w))
					cnt++;
			} if (word.equalsIgnoreCase(w))
					cnt++; word.equalsIgnoreCase(w) word.equalsIgnoreCase word w cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	}
}