import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=br.readLine();
        String[] T;
        int c=0;
        while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        }
        System.out.println(c);
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=br.readLine();
        String[] T;
        int c=0;
        while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        }
        System.out.println(c);
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=br.readLine();
        String[] T;
        int c=0;
        while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        }
        System.out.println(c);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=br.readLine();
        String[] T;
        int c=0;
        while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        }
        System.out.println(c);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W=br.readLine(); W br.readLine() br.readLine br String[] T; T int c=0; c 0 while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        } true {
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        } T=br.readLine().split(" ") T br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " if(T[0].equals("END_OF_TEXT")) break; T[0].equals("END_OF_TEXT") T[0].equals T[0] T 0 "END_OF_TEXT" break; for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            } String str T {
              if(str.equalsIgnoreCase(W)) c++;
            } {
              if(str.equalsIgnoreCase(W)) c++;
            } if(str.equalsIgnoreCase(W)) c++; str.equalsIgnoreCase(W) str.equalsIgnoreCase str W c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=br.readLine();
        String[] T;
        int c=0;
        while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        }
        System.out.println(c);
	}
}