

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//ArrayList<String> word = new ArrayList<String>();
		String[] words;
		int wordCount = 0;
		String W = scan.nextLine();
		String T = "";
		
		
		
	
		while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		}
		
		
		System.out.println(wordCount);
		
		
	}
	

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

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//ArrayList<String> word = new ArrayList<String>();
		String[] words;
		int wordCount = 0;
		String W = scan.nextLine();
		String T = "";
		
		
		
	
		while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		}
		
		
		System.out.println(wordCount);
		
		
	} main {
		Scanner scan = new Scanner(System.in);
		//ArrayList<String> word = new ArrayList<String>();
		String[] words;
		int wordCount = 0;
		String W = scan.nextLine();
		String T = "";
		
		
		
	
		while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		}
		
		
		System.out.println(wordCount);
		
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String[] words; words int wordCount = 0; wordCount 0 String W = scan.nextLine(); W scan.nextLine() scan.nextLine scan String T = ""; T "" while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		} true {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		} T = scan.nextLine() T scan.nextLine() scan.nextLine scan if(T.equals("END_OF_TEXT")) break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; words = T.toLowerCase().split(" ") words T.toLowerCase().split(" ") T.toLowerCase().split T.toLowerCase() T.toLowerCase T " " for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			} int j = 0; int j = 0; j 0 j < words.length j words.length words words.length j++ j++ j {
				if(words[j].equals(W)){
					wordCount++;
				}
			} {
				if(words[j].equals(W)){
					wordCount++;
				}
			} if(words[j].equals(W)){
					wordCount++;
				} words[j].equals(W) words[j].equals words[j] words j W {
					wordCount++;
				} wordCount++ wordCount System.out.println(wordCount) System.out.println System.out System System.out wordCount String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//ArrayList<String> word = new ArrayList<String>();
		String[] words;
		int wordCount = 0;
		String W = scan.nextLine();
		String T = "";
		
		
		
	
		while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		}
		
		
		System.out.println(wordCount);
		
		
	}
	

} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//ArrayList<String> word = new ArrayList<String>();
		String[] words;
		int wordCount = 0;
		String W = scan.nextLine();
		String T = "";
		
		
		
	
		while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		}
		
		
		System.out.println(wordCount);
		
		
	}
	

} Main


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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//ArrayList<String> word = new ArrayList<String>();
		String[] words;
		int wordCount = 0;
		String W = scan.nextLine();
		String T = "";
		
		
		
	
		while(true) {
			T = scan.nextLine();
			if(T.equals("END_OF_TEXT")) break;
			words = T.toLowerCase().split(" ");
			for (int j = 0; j < words.length; j++) {
				if(words[j].equals(W)){
					wordCount++;
				}
			}
			
		}
		
		
		System.out.println(wordCount);
		
		
	}
	

}