import java.util.Scanner;
import java.io.*;
 
class Main {
    public static void main(String[] args)throws IOException{ 
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
                                                              
        String W = reader.readLine();
        String Tall = "";
         
        while(true){
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        }
        String low_T = Tall.toLowerCase();
        int sum = 0;
         
         
        String [] item = low_T.split(" ");
         
         
        for(int itemNum = 0; itemNum < (item.length); itemNum++){
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        }
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util import java.io.*; io.* java class Main {
    public static void main(String[] args)throws IOException{ 
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
                                                              
        String W = reader.readLine();
        String Tall = "";
         
        while(true){
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        }
        String low_T = Tall.toLowerCase();
        int sum = 0;
         
         
        String [] item = low_T.split(" ");
         
         
        for(int itemNum = 0; itemNum < (item.length); itemNum++){
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args)throws IOException{ 
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
                                                              
        String W = reader.readLine();
        String Tall = "";
         
        while(true){
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        }
        String low_T = Tall.toLowerCase();
        int sum = 0;
         
         
        String [] item = low_T.split(" ");
         
         
        for(int itemNum = 0; itemNum < (item.length); itemNum++){
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        }
        System.out.println(sum);
    } main { 
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
                                                              
        String W = reader.readLine();
        String Tall = "";
         
        while(true){
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        }
        String low_T = Tall.toLowerCase();
        int sum = 0;
         
         
        String [] item = low_T.split(" ");
         
         
        for(int itemNum = 0; itemNum < (item.length); itemNum++){
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        }
        System.out.println(sum);
    } InputStreamReader in = new InputStreamReader(System.in); in new InputStreamReader(System.in) BufferedReader reader = new BufferedReader(in); reader new BufferedReader(in) String W = reader.readLine(); W reader.readLine() reader.readLine reader String Tall = ""; Tall "" while(true){
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        } true {
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        } String T = reader.readLine(); T reader.readLine() reader.readLine reader if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        } T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
            break;
        } break; {
        Tall = Tall+" " + T; 
        } Tall = Tall+" " + T Tall Tall+" " + T Tall+" " + T Tall " " T String low_T = Tall.toLowerCase(); low_T Tall.toLowerCase() Tall.toLowerCase Tall int sum = 0; sum 0 String [] item = low_T.split(" "); item low_T.split(" ") low_T.split low_T " " for(int itemNum = 0; itemNum < (item.length); itemNum++){
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        } int itemNum = 0; int itemNum = 0; itemNum 0 itemNum < (item.length) itemNum (item.length) item item.length itemNum++ itemNum++ itemNum {
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        } {
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        } if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            } item [itemNum].equals(W) item [itemNum].equals item [itemNum] item itemNum W {
            sum++;
            } sum++ sum {
            } System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;
import java.io.*;
 
class Main {
    public static void main(String[] args)throws IOException{ 
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
                                                              
        String W = reader.readLine();
        String Tall = "";
         
        while(true){
        String T = reader.readLine();
        //String low_T = T.toLowerCase();
        if(T.equals("END_OF_TEXT")){
            break;
        }
        else{
        Tall = Tall+" " + T; 
        }
        }
        String low_T = Tall.toLowerCase();
        int sum = 0;
         
         
        String [] item = low_T.split(" ");
         
         
        for(int itemNum = 0; itemNum < (item.length); itemNum++){
            if(item [itemNum].equals(W)){
            sum++;
            }
            else{
            }
        }
        System.out.println(sum);
    }
}