import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	}

	public static boolean EndDecision(String[] array) {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	}

}
 import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	}

	public static boolean EndDecision(String[] array) {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	} main {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc ArrayList<String> T = new ArrayList<String>(); T new ArrayList<String>() String[] input; input while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		} EndDecision(input = sc.nextLine().split("[\\s]+")) EndDecision input = sc.nextLine().split("[\\s]+") input sc.nextLine().split("[\\s]+") sc.nextLine().split sc.nextLine() sc.nextLine sc "[\\s]+" {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		} for (String str : input) {
				T.add(str.toLowerCase());
			} String str input {
				T.add(str.toLowerCase());
			} {
				T.add(str.toLowerCase());
			} T.add(str.toLowerCase()) T.add T str.toLowerCase() str.toLowerCase str int count = 0; count 0 for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		} String str T {
			if (W.equals(str)) {
				count++;
			}
		} {
			if (W.equals(str)) {
				count++;
			}
		} if (W.equals(str)) {
				count++;
			} W.equals(str) W.equals W str {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public static boolean EndDecision(String[] array) {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	} EndDecision {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	} if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		} array[0].equals("END_OF_TEXT") array[0].equals array[0] array 0 "END_OF_TEXT" {
			return false;
		} return false; false {
			return true;
		} return true; true String[] array array public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	}

	public static boolean EndDecision(String[] array) {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	}

	public static boolean EndDecision(String[] array) {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	}

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();

		ArrayList<String> T = new ArrayList<String>();
		String[] input;
		while (EndDecision(input = sc.nextLine().split("[\\s]+"))) {
			for (String str : input) {
				T.add(str.toLowerCase());
			}
		}

		int count = 0;
		for (String str : T) {
			if (W.equals(str)) {
				count++;
			}
		}

		System.out.println(count);

	}

	public static boolean EndDecision(String[] array) {
		if (array[0].equals("END_OF_TEXT")) {
			return false;
		} else {
			return true;
		}

	}

}

