import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String[] words; words int intCount = 0; intCount 0 String strWord = scan.nextLine(); strWord scan.nextLine() scan.nextLine scan String strIn = ""; strIn "" while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		} true {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		} strIn = scan.nextLine() strIn scan.nextLine() scan.nextLine scan if(strIn.equals("END_OF_TEXT")){
				break;
			} strIn.equals("END_OF_TEXT") strIn.equals strIn "END_OF_TEXT" {
				break;
			} break; words = strIn.toLowerCase().split(" ") words strIn.toLowerCase().split(" ") strIn.toLowerCase().split strIn.toLowerCase() strIn.toLowerCase strIn " " for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			} int j = 0; int j = 0; j 0 j < words.length j words.length words words.length j++ j++ j {
				if(words[j].equals(strWord)){
					intCount++;
				}
			} {
				if(words[j].equals(strWord)){
					intCount++;
				}
			} if(words[j].equals(strWord)){
					intCount++;
				} words[j].equals(strWord) words[j].equals words[j] words j strWord {
					intCount++;
				} intCount++ intCount System.out.println(intCount) System.out.println System.out System System.out intCount scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] words;
		int intCount = 0;
		String strWord = scan.nextLine();
		String strIn = "";
		while(true) {
			strIn = scan.nextLine();
			if(strIn.equals("END_OF_TEXT")){
				break;
			}
			words = strIn.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(strWord)){
					intCount++;
				}
			}
		}
		System.out.println(intCount);
		scan.close();
	}
}