
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String word = sc.nextLine(); word sc.nextLine() sc.nextLine sc int count = 0; count 0 while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		} true {
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		} String S = sc.next(); S sc.next() sc.next sc if(S.equals("END_OF_TEXT")){
				break;
			} S.equals("END_OF_TEXT") S.equals S "END_OF_TEXT" {
				break;
			} break; String text = S.toLowerCase(); text S.toLowerCase() S.toLowerCase S if(text.equals(word)){
				count++;
			} text.equals(word) text.equals text word {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String args[] args public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} Main

import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String word = sc.nextLine();
		int count = 0;

		while(true){
			String S = sc.next();

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

			String text = S.toLowerCase();

			if(text.equals(word)){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}