import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	}

}
 import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	}

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

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	} main {

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String keyWord = sc.next(); keyWord sc.next() sc.next sc keyWord = keyWord.toUpperCase() keyWord keyWord.toUpperCase() keyWord.toUpperCase keyWord ArrayList<String> wordLists = new ArrayList<>(); wordLists new ArrayList<>() while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		} true {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		} String word = sc.next(); word sc.next() sc.next sc if(word.equals("END_OF_TEXT")) break; word.equals("END_OF_TEXT") word.equals word "END_OF_TEXT" break; wordLists.add(word.toUpperCase()) wordLists.add wordLists word.toUpperCase() word.toUpperCase word sc.close() sc.close sc int count = 0; count 0 for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		} String word wordLists {
			if(word.equals(keyWord)) count++;
		} {
			if(word.equals(keyWord)) count++;
		} if(word.equals(keyWord)) count++; word.equals(keyWord) word.equals word keyWord 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) {

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	}

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String keyWord = sc.next();
		keyWord = keyWord.toUpperCase();

		ArrayList<String> wordLists = new ArrayList<>();
		while(true) {
			String word = sc.next();
			if(word.equals("END_OF_TEXT")) break;
			wordLists.add(word.toUpperCase());
		}

		sc.close();

		// 単語数を計測
		int count = 0;
		for(String word : wordLists) {
			if(word.equals(keyWord)) count++;
		}

		System.out.println(count);

	}

}

