import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	}
} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	} main {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	} String w = sc.next(); w sc.next() sc.next sc w = w.toLowerCase() w w.toLowerCase() w.toLowerCase w String s = ""; s "" int count = 0; count 0 while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		} sc.hasNext() sc.hasNext sc {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		} String str = sc.next(); str sc.next() sc.next sc if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {break;} break; {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			} str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str if (str.equals(w)) {count++;} str.equals(w) str.equals str w {count++;} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String w = sc.next();
		w = w.toLowerCase();
		String s = "";
		int count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT")) {break;}
			else {
				str = str.toLowerCase();
				if (str.equals(w)) {count++;}
			}
		}
		System.out.println(count);
	}
}
