import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	} main {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String w = scan.next(); w scan.next() scan.next scan w = w.toLowerCase() w w.toLowerCase() w.toLowerCase w String ti; ti while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		} true {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		} ti = scan.next() ti scan.next() scan.next scan if ( ti.equals("END_OF_TEXT") ) break; ti.equals("END_OF_TEXT") ti.equals ti "END_OF_TEXT" break; sb.append(ti + " ") sb.append sb ti + " " ti " " String[] stary = sb.toString().split(" "); stary sb.toString().split(" ") sb.toString().split sb.toString() sb.toString sb " " int count = 0; count 0 for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < stary.length i stary.length stary stary.length i++ i++ i {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		} {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		} if (stary[i].toLowerCase().equals(w)) {
				count++;
			} stary[i].toLowerCase().equals(w) stary[i].toLowerCase().equals stary[i].toLowerCase() stary[i].toLowerCase stary[i] stary i w {
				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) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String w = scan.next();
		w = w.toLowerCase();
		String ti;
		while (true) {
			ti = scan.next();
			if ( ti.equals("END_OF_TEXT") ) break;
			sb.append(ti + " ");
		}
		String[] stary = sb.toString().split(" ");
		int count = 0;
		for (int i = 0; i < stary.length; i++) {
			if (stary[i].toLowerCase().equals(w)) {
				count++;
			}
		}
		System.out.println(count);
	}
}