import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().toLowerCase();
		int cnt=0;
		while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		}
		System.out.println(cnt);
	}
} import java.io.*; io.* java class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().toLowerCase();
		int cnt=0;
		while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().toLowerCase();
		int cnt=0;
		while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().toLowerCase();
		int cnt=0;
		while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		}
		System.out.println(cnt);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine().toLowerCase(); str br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br int cnt=0; cnt 0 while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		} true {
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		} String[] str2 = br.readLine().split(" "); str2 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " if(str2[0].equals("END_OF_TEXT")) break; str2[0].equals("END_OF_TEXT") str2[0].equals str2[0] str2 0 "END_OF_TEXT" break; for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			} int i=0; int i=0; i 0 i<str2.length i str2.length str2 str2.length i++ i++ i {
				if(str2[i].toLowerCase().equals(str)) cnt++;
			} {
				if(str2[i].toLowerCase().equals(str)) cnt++;
			} if(str2[i].toLowerCase().equals(str)) cnt++; str2[i].toLowerCase().equals(str) str2[i].toLowerCase().equals str2[i].toLowerCase() str2[i].toLowerCase str2[i] str2 i str cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().toLowerCase();
		int cnt=0;
		while(true){
			String[] str2 = br.readLine().split(" ");
			if(str2[0].equals("END_OF_TEXT")) break;
			for(int i=0; i<str2.length; i++){
				if(str2[i].toLowerCase().equals(str)) cnt++;
			}
		}
		System.out.println(cnt);
	}
}