import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String w = br.readLine(); w br.readLine() br.readLine br String line; line int count = 0; count 0 while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		} !(line = br.readLine()).equals("END_OF_TEXT") (line = br.readLine()).equals("END_OF_TEXT") (line = br.readLine()).equals (line = br.readLine()) line br.readLine() br.readLine br "END_OF_TEXT" {
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		} line = line.toLowerCase() line line.toLowerCase() line.toLowerCase line String[] words = line.split(" "); words line.split(" ") line.split line " " for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			} int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
				if(words[i].equals(w)){
					count++;
				}
			} {
				if(words[i].equals(w)){
					count++;
				}
			} if(words[i].equals(w)){
					count++;
				} words[i].equals(w) words[i].equals words[i] words i w {
					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) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		String line;
		int count = 0;
		while(!(line = br.readLine()).equals("END_OF_TEXT")){
			line = line.toLowerCase();
			String[] words = line.split(" ");
			for(int i = 0;i < words.length;i++){
				if(words[i].equals(w)){
					count++;
				}
			}
		}
		System.out.println(count);
	}

}