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 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().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 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().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 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					}
		}

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

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

		Scanner scan = new Scanner(System.in);

		String str1 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().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 =scan.nextLine(); str1 scan.nextLine() scan.nextLine scan String str2; str2 int count =0; count 0 while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					}
		} true {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					}
		} str2 = scan.nextLine() str2 scan.nextLine() scan.nextLine scan if (str2.equals("END_OF_TEXT")) {
					break;
				} str2.equals("END_OF_TEXT") str2.equals str2 "END_OF_TEXT" {
					break;
				} break; Scanner sb = new Scanner(str2); sb new Scanner(str2) while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					} sb.hasNext() sb.hasNext sb {


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					} if(sb.next().equalsIgnoreCase(str1)){
						count++;

					} sb.next().equalsIgnoreCase(str1) sb.next().equalsIgnoreCase sb.next() sb.next sb 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 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					}
		}

		System.out.println(count);
 }

}