import java.util.*;

public class Main {

	public static void main(String[] args) {
		String w, temp;
		int counter = 0;
		Scanner sc = new Scanner(System.in);
		w = sc.next().toLowerCase();
		while (true) {
			temp = sc.next();
			if(temp.toLowerCase().equals(w))
				counter++;
			if(temp.equals("END_OF_TEXT"))
				break;
		}
		System.out.println(counter);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		String w, temp;
		int counter = 0;
		Scanner sc = new Scanner(System.in);
		w = sc.next().toLowerCase();
		while (true) {
			temp = sc.next();
			if(temp.toLowerCase().equals(w))
				counter++;
			if(temp.equals("END_OF_TEXT"))
				break;
		}
		System.out.println(counter);
	}

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

	public static void main(String[] args) {
		String w, temp;
		int counter = 0;
		Scanner sc = new Scanner(System.in);
		w = sc.next().toLowerCase();
		while (true) {
			temp = sc.next();
			if(temp.toLowerCase().equals(w))
				counter++;
			if(temp.equals("END_OF_TEXT"))
				break;
		}
		System.out.println(counter);
	}

} public class Main {

	public static void main(String[] args) {
		String w, temp;
		int counter = 0;
		Scanner sc = new Scanner(System.in);
		w = sc.next().toLowerCase();
		while (true) {
			temp = sc.next();
			if(temp.toLowerCase().equals(w))
				counter++;
			if(temp.equals("END_OF_TEXT"))
				break;
		}
		System.out.println(counter);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		String w, temp;
		int counter = 0;
		Scanner sc = new Scanner(System.in);
		w = sc.next().toLowerCase();
		while (true) {
			temp = sc.next();
			if(temp.toLowerCase().equals(w))
				counter++;
			if(temp.equals("END_OF_TEXT"))
				break;
		}
		System.out.println(counter);
	}

}