import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

} Main public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	} main {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	} int count = 0; count 0 String str; str Scanner sc = new Scanner(System.in); sc new Scanner(System.in) str = sc.next() str sc.next() sc.next sc while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		} true {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		} String tmp = sc.next(); tmp sc.next() sc.next sc if (tmp.equals("END_OF_TEXT")) {
				break;
			} tmp.equals("END_OF_TEXT") tmp.equals tmp "END_OF_TEXT" {
				break;
			} break; if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			} str.length() == tmp.length() str.length() str.length str tmp.length() tmp.length tmp {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			} if (str.equalsIgnoreCase(tmp)){
					++count;
				} str.equalsIgnoreCase(tmp) str.equalsIgnoreCase str tmp {
					++count;
				} ++count count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		String str;
		Scanner sc = new Scanner(System.in);
		str = sc.next(); // ??????W
		while (true) {
			String tmp = sc.next();
			if (tmp.equals("END_OF_TEXT")) {
				break;
			}
			if (str.length() == tmp.length()) {
				if (str.equalsIgnoreCase(tmp)){
					++count;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

}