import java.io.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	}
} import java.io.*; io.* java import java.util.regex.Pattern; Pattern java.util.regex import java.util.regex.Matcher; Matcher java.util.regex public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String key = br.readLine(); key br.readLine() br.readLine br int count=0; count 0 String line=br.readLine(); line br.readLine() br.readLine br String[] words = line.split(" ",0); words line.split(" ",0) line.split line " " 0 while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		} !line.equals("END_OF_TEXT") line.equals("END_OF_TEXT") line.equals line "END_OF_TEXT" {
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		} for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			} int i=0; int i=0; i 0 i<words.length i words.length words words.length i++ i++ i {
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			} {
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			} if(key.equalsIgnoreCase(words[i])){
					count++;
				} key.equalsIgnoreCase(words[i]) key.equalsIgnoreCase key words[i] words i {
					count++;
				} count++ count line=br.readLine() line br.readLine() br.readLine br words = line.split(" ") words line.split(" ") line.split line " " 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) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	}
} Main
import java.io.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String key = br.readLine();
		int count=0;
		//Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
		String line=br.readLine();
		String[] words = line.split(" ",0);
		while(!line.equals("END_OF_TEXT")){
			for(int i=0;i<words.length;i++){
				if(key.equalsIgnoreCase(words[i])){
					count++;
				}
			}
			line=br.readLine();
			words = line.split(" ");
		}
		System.out.println(count);
	}
}