import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	}
} Main static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; k {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'} 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	} main {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String W = stdIn.next(); W stdIn.next() stdIn.next stdIn W = W.toLowerCase() W W.toLowerCase() W.toLowerCase W int k = 0; k 0 while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		} true {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		} String T = stdIn.next(); T stdIn.next() stdIn.next stdIn if(T.equals("END_OF_TEXT")) {
				break;
			} T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
				break;
			} break; T = T.toLowerCase() T T.toLowerCase() T.toLowerCase T if(T.equals(W)) {
				k++;
			} T.equals(W) T.equals T W {
				k++;
			} k++ k System.out.println(k) System.out.println System.out System System.out k String[] args args public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	}
} public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	}
} Main
import java.util.Scanner;
public class Main {
	
	static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		W = W.toLowerCase();
		int k = 0;
		while(true) {
			String T = stdIn.next();
			if(T.equals("END_OF_TEXT")) {
				break;
			}
			T = T.toLowerCase();
			if(T.equals(W)) {
				k++;
			}
		}
		System.out.println(k);
	}
}