

import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	}
} import java.util.*; util.* java public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	}
} Main public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	} main {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str str W; W int result = -1; result -1 1 int sum = 0; sum 0 W = scan.next().toLowerCase() W scan.next().toLowerCase() scan.next().toLowerCase scan.next() scan.next scan while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		} true {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		} str = scan.next() str scan.next() scan.next scan if (str.equals("END_OF_TEXT")) {
				break;
			} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
				break;
			} break; str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str result = str.indexOf(W) result str.indexOf(W) str.indexOf str W if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			} (result == 0) & (str.length() == W.length()) (result == 0) result 0 (str.length() == W.length()) str.length() str.length str W.length() W.length W {
				sum++;
				result = -1;
			} sum++ sum result = -1 result -1 1 System.out.println(sum) System.out.println System.out System System.out sum String args[] args public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	}
} public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	}
} Main


import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		String str, W;
		int result = -1;// ?????????
		int sum = 0;// ????¨????

		W = scan.next().toLowerCase();

		while (true) {

			str = scan.next();

			// END_OF_TEXT??§????????????
			if (str.equals("END_OF_TEXT")) {
				break;
			}
			// END_OF_TEXT??????????????£????????????????????????????????§?°??????????
			str = str.toLowerCase();

			// 1????????????????????????0?????¨??????????????????
			result = str.indexOf(W);
			if ((result == 0) & (str.length() == W.length())) {
				sum++;
				result = -1;
			}
		}

		System.out.println(sum);

	}
}