import java.io.*;

public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    }
} import java.io.*; io.* java public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    }
} Main public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str String keyword = br.readLine(); keyword br.readLine() br.readLine br keyword = keyword.toLowerCase() keyword keyword.toLowerCase() keyword.toLowerCase keyword int count = 0; count 0 while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        } !(str = br.readLine()).equals("END_OF_TEXT") (str = br.readLine()).equals("END_OF_TEXT") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "END_OF_TEXT" {
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        } str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str String[] word = str.split(" "); word str.split(" ") str.split str " " for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            } int i=0; int i=0; i 0 i<word.length i word.length word word.length i++ i++ i {
                if(word[i].equals(keyword)){
                    count++;
                }
            } {
                if(word[i].equals(keyword)){
                    count++;
                }
            } if(word[i].equals(keyword)){
                    count++;
                } word[i].equals(keyword) word[i].equals word[i] word i keyword {
                    count++;
                } count++ count System.out.println(count) System.out.println System.out System System.out count String[]args args public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    }
} public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    }
} Main
import java.io.*;

public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        String keyword = br.readLine();
        keyword = keyword.toLowerCase();
        int count = 0;
        
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            str = str.toLowerCase();
            String[] word = str.split(" ");

            for(int i=0; i<word.length; i++){
                if(word[i].equals(keyword)){
                    count++;
                }
            }      
        }
        System.out.println(count);
    }
}