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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		String search = br.readLine().toLowerCase();

		while(true){

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		}

		System.out.println(count);

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

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		String search = br.readLine().toLowerCase();

		while(true){

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		}

		System.out.println(count);

	}
} Main public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		String search = br.readLine().toLowerCase();

		while(true){

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		}

		System.out.println(count);

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		String search = br.readLine().toLowerCase();

		while(true){

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		}

		System.out.println(count);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int count = 0; count 0 String search = br.readLine().toLowerCase(); search br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br while(true){

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		} true {

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		} String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("END_OF_TEXT")){
				break;
			} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
				break;
			} break; str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str String[] word = str.split(" "); word str.split(" ") str.split str " " for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			} int i = 0; int i = 0; i 0 i < word.length i word.length word word.length i++ i++ i {
				if(search.equals(word[i])){
					count++;
				}
			} {
				if(search.equals(word[i])){
					count++;
				}
			} if(search.equals(word[i])){
					count++;
				} search.equals(word[i]) search.equals search word[i] word i {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
		String search = br.readLine().toLowerCase();

		while(true){

			String str = br.readLine();

			if(str.equals("END_OF_TEXT")){
				break;
			}

			str = str.toLowerCase();
			String[] word = str.split(" ");

			for(int i = 0; i < word.length; i++){
				if(search.equals(word[i])){
					count++;
				}
			}

		}

		System.out.println(count);

	}
}