import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	}	
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	}	
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc W = W.toLowerCase() W W.toLowerCase() W.toLowerCase W int num = 0; num 0 for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		} ; {
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		} {
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		} String T = sc.next(); T sc.next() sc.next sc 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))num++; W.equals(T) W.equals W T num++ num System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	}	
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	}	
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		W = W.toLowerCase();
		int num = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT"))break;
			T = T.toLowerCase();
			if(W.equals(T))num++;
		}
		System.out.println(num);
	}	
}