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

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} 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) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	} try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String w = reader.readLine(); w reader.readLine() reader.readLine reader String text; text String[] t; t int count = 0; count 0 while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			} !(text = reader.readLine()).equals("END_OF_TEXT") (text = reader.readLine()).equals("END_OF_TEXT") (text = reader.readLine()).equals (text = reader.readLine()) text reader.readLine() reader.readLine reader "END_OF_TEXT" {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			} text = text.toLowerCase() text text.toLowerCase() text.toLowerCase text t = text.split(" ") t text.split(" ") text.split text " " for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				} int i = 0; int i = 0; i 0 i < t.length i t.length t t.length i++ i++ i {
					if (w.equals(t[i])) {
						count++;
					}
				} {
					if (w.equals(t[i])) {
						count++;
					}
				} if (w.equals(t[i])) {
						count++;
					} w.equals(t[i]) w.equals w t[i] t i {
						count++;
					} count++ count 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) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String w = reader.readLine();
			
			String text;
			String[] t;
			
			int count = 0;
			while (!(text = reader.readLine()).equals("END_OF_TEXT")) {
				text = text.toLowerCase();
				t = text.split(" ");
				for (int i = 0; i < t.length; i++) {
					if (w.equals(t[i])) {
						count++;
					}
				}
			}
			System.out.println(count);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}