import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String s = buf.readLine().toLowerCase();
		String[] str;
		int count=0;

		while(true){
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		}
		System.out.println(count);
	}
} import java.io.*; io.* java class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String s = buf.readLine().toLowerCase();
		String[] str;
		int count=0;

		while(true){
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		}
		System.out.println(count);
	}
} Main public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String s = buf.readLine().toLowerCase();
		String[] str;
		int count=0;

		while(true){
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		}
		System.out.println(count);
	} main {
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String s = buf.readLine().toLowerCase();
		String[] str;
		int count=0;

		while(true){
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		}
		System.out.println(count);
	} BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) String s = buf.readLine().toLowerCase(); s buf.readLine().toLowerCase() buf.readLine().toLowerCase buf.readLine() buf.readLine buf String[] str; str int count=0; count 0 while(true){
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		} true {
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		} str = buf.readLine().split(" ") str buf.readLine().split(" ") buf.readLine().split buf.readLine() buf.readLine buf " " 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(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			} {
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			} if(s.equals(str[i].toLowerCase()))
					count++; s.equals(str[i].toLowerCase()) s.equals s str[i].toLowerCase() str[i].toLowerCase str[i] str i count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String s = buf.readLine().toLowerCase();
		String[] str;
		int count=0;

		while(true){
			str = buf.readLine().split(" ");
			if(str[0].equals("END_OF_TEXT"))
				break;

			for(int i=0; i<str.length; i++){
				
				if(s.equals(str[i].toLowerCase()))
					count++;
			}

		}
		System.out.println(count);
	}
}