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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br String w = str; w str str = br.readLine() str br.readLine() br.readLine br Boolean isEnd = str.equals("END_OF_TEXT"); isEnd str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" int count = 0; count 0 while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		} !isEnd isEnd {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		} String[] words = str.split(" ", 0); words str.split(" ", 0) str.split str " " 0 for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			} String word words {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			} {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			} if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				} word.equalsIgnoreCase(w) == true word.equalsIgnoreCase(w) word.equalsIgnoreCase word w true {
					count = count + 1;
				} count = count + 1 count count + 1 count 1 str = br.readLine() str br.readLine() br.readLine br isEnd = str.equals("END_OF_TEXT") isEnd str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String w = str;
		str = br.readLine();
		Boolean isEnd = str.equals("END_OF_TEXT");
		int count = 0;
		while (!isEnd) {
			String[] words = str.split(" ", 0);
			for (String word : words) {
				if (word.equalsIgnoreCase(w) == true) {
					count = count + 1;
				}
			}
			str = br.readLine();
			isEnd = str.equals("END_OF_TEXT");
		}
		System.out.println(count);
	}
}