import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		String Ward =scan.nextLine();
		String tem = "";
		int out = 0;
		ArrayList<String> T = new ArrayList<String>();
		while(!tem.equals("END_OF_TEXT")){
			tem = scan.next();
			T.add(tem) ;
		}
		for(int i=0; i<T.size()-1; i++){
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		}
		System.out.println(out);
	}
} import java.io.IOException; IOException java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		String Ward =scan.nextLine();
		String tem = "";
		int out = 0;
		ArrayList<String> T = new ArrayList<String>();
		while(!tem.equals("END_OF_TEXT")){
			tem = scan.next();
			T.add(tem) ;
		}
		for(int i=0; i<T.size()-1; i++){
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		}
		System.out.println(out);
	}
} Main public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		String Ward =scan.nextLine();
		String tem = "";
		int out = 0;
		ArrayList<String> T = new ArrayList<String>();
		while(!tem.equals("END_OF_TEXT")){
			tem = scan.next();
			T.add(tem) ;
		}
		for(int i=0; i<T.size()-1; i++){
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		}
		System.out.println(out);
	} main {
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		String Ward =scan.nextLine();
		String tem = "";
		int out = 0;
		ArrayList<String> T = new ArrayList<String>();
		while(!tem.equals("END_OF_TEXT")){
			tem = scan.next();
			T.add(tem) ;
		}
		for(int i=0; i<T.size()-1; i++){
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		}
		System.out.println(out);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String Ward =scan.nextLine(); Ward scan.nextLine() scan.nextLine scan String tem = ""; tem "" int out = 0; out 0 ArrayList<String> T = new ArrayList<String>(); T new ArrayList<String>() while(!tem.equals("END_OF_TEXT")){
			tem = scan.next();
			T.add(tem) ;
		} !tem.equals("END_OF_TEXT") tem.equals("END_OF_TEXT") tem.equals tem "END_OF_TEXT" {
			tem = scan.next();
			T.add(tem) ;
		} tem = scan.next() tem scan.next() scan.next scan T.add(tem) T.add T tem for(int i=0; i<T.size()-1; i++){
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		} int i=0; int i=0; i 0 i<T.size()-1 i T.size()-1 T.size() T.size T 1 i++ i++ i {
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		} {
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		} if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			} T.get(i).equalsIgnoreCase(Ward) T.get(i).equalsIgnoreCase T.get(i) T.get T i Ward {
				out += 1 ;
			} out += 1 out 1 System.out.println(out) System.out.println System.out System System.out out String[] args args
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		String Ward =scan.nextLine();
		String tem = "";
		int out = 0;
		ArrayList<String> T = new ArrayList<String>();
		while(!tem.equals("END_OF_TEXT")){
			tem = scan.next();
			T.add(tem) ;
		}
		for(int i=0; i<T.size()-1; i++){
			if(T.get(i).equalsIgnoreCase(Ward)){
				out += 1 ;
			}
		}
		System.out.println(out);
	}
}