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

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

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				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 input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

		System.out.println(count);
	}
}//??§???????°?????????????????°???????????????????????????? Main public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

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

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

		System.out.println(count);
	} BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) String keyword = input.readLine(); keyword input.readLine() input.readLine input String str_containing_key = ""; str_containing_key "" int count=0; count 0 while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		} true {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		} str_containing_key = input.readLine() str_containing_key input.readLine() input.readLine input if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			} str_containing_key.equals("END_OF_TEXT") str_containing_key.equals str_containing_key "END_OF_TEXT" {

				break;

			} break; String []str_array=str_containing_key.split(" "); str_array str_containing_key.split(" ") str_containing_key.split str_containing_key " " for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			} int array_spot=0; int array_spot=0; array_spot 0 array_spot<str_array.length array_spot str_array.length str_array str_array.length array_spot++ array_spot++ array_spot {


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			} {


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			} if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			} str_array[array_spot].equalsIgnoreCase(keyword) str_array[array_spot].equalsIgnoreCase str_array[array_spot] str_array array_spot keyword {

				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 input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

		System.out.println(count);
	}
}//??§???????°?????????????????°???????????????????????????? public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				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 input = new BufferedReader(new InputStreamReader(System.in));

		String keyword = input.readLine();

		String str_containing_key = "";

		int count=0;



		while (true) {

			str_containing_key = input.readLine();

			if (str_containing_key.equals("END_OF_TEXT")) {

				break;

			}

			String []str_array=str_containing_key.split(" ");

			for(int array_spot=0; array_spot<str_array.length; array_spot++){


			if(str_array[array_spot].equalsIgnoreCase(keyword)){

				count++;
			}
			}

		}

		System.out.println(count);
	}
}//??§???????°?????????????????°????????????????????????????