import java.util.*;
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String W = scanner.next();
		int count = 0;
		while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		}
		System.out.println(count);
	}
}
 import java.util.*; util.* java import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String W = scanner.next();
		int count = 0;
		while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String W = scanner.next();
		int count = 0;
		while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		}
		System.out.println(count);
	} main {
		Scanner scanner = new Scanner(System.in);
		String W = scanner.next();
		int count = 0;
		while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		}
		System.out.println(count);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String W = scanner.next(); W scanner.next() scanner.next scanner int count = 0; count 0 while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		} true {
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		} String T = scanner.next(); T scanner.next() scanner.next scanner if(T.equals("END_OF_TEXT"))
				break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; T = T.toLowerCase() T T.toLowerCase() T.toLowerCase T if(W.equals(T))
				count ++; W.equals(T) W.equals W T count ++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String W = scanner.next();
		int count = 0;
		while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		}
		System.out.println(count);
	}
}

