import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	} final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String key=sc.nextLine().toLowerCase(); key sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int count = 0; count 0 while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		} true {
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		} String[] str=sc.nextLine().split(" "); str sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " if(str[0].equals("END_OF_TEXT")) break; str[0].equals("END_OF_TEXT") str[0].equals str[0] str 0 "END_OF_TEXT" break; for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			} String s str {
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			} {
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			} s=s.toLowerCase() s s.toLowerCase() s.toLowerCase s if(s.equals(key)) {
					count++;
				} s.equals(key) s.equals s key {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		String key=sc.nextLine().toLowerCase();
		int count = 0;
		while(true){
			String[] str=sc.nextLine().split(" ");
			if(str[0].equals("END_OF_TEXT")) break;
			for(String s:str){
				s=s.toLowerCase();
				if(s.equals(key)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}