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


class Main {

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

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

		Scanner scan = new Scanner(System.in);

		String str1 = br.readLine();

		String str2;

		int count =0;

		while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						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 import java.util.Scanner; Scanner java.util class Main {

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

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

		Scanner scan = new Scanner(System.in);

		String str1 = br.readLine();

		String str2;

		int count =0;

		while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		}

		System.out.println(count);
 }

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

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

		Scanner scan = new Scanner(System.in);

		String str1 = br.readLine();

		String str2;

		int count =0;

		while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		}

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

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

		Scanner scan = new Scanner(System.in);

		String str1 = br.readLine();

		String str2;

		int count =0;

		while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		}

		System.out.println(count);
 } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str1 = br.readLine(); str1 br.readLine() br.readLine br String str2; str2 int count =0; count 0 while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		} true {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		} str2 = br.readLine() str2 br.readLine() br.readLine br String[] st = str2.split(" "); st str2.split(" ") str2.split str2 " " if(st[0].equals("END_OF_TEXT")){
				break;
			} st[0].equals("END_OF_TEXT") st[0].equals st[0] st 0 "END_OF_TEXT" {
				break;
			} break; for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				} String s st {
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				} {
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				} if(s.equalsIgnoreCase(str1)){
						count++;

					} s.equalsIgnoreCase(str1) s.equalsIgnoreCase s str1 {
						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.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class Main {

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

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

		Scanner scan = new Scanner(System.in);

		String str1 = br.readLine();

		String str2;

		int count =0;

		while (true) {

			str2 = br.readLine();
			String[] st = str2.split(" ");

			if(st[0].equals("END_OF_TEXT")){
				break;
			}

				for(String s: st){
					if(s.equalsIgnoreCase(str1)){
						count++;

					}
				}
		}

		System.out.println(count);
 }

}