import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    } main {
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String word; word String[] sen = new String[1000]; sen new String[1000] 1000 int i=0; i 0 word = scan.next() word scan.next() scan.next scan while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        } true {
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        } sen[i] = scan.next() sen[i] sen i scan.next() scan.next scan if(sen[i].equals("END_OF_TEXT"))break; sen[i].equals("END_OF_TEXT") sen[i].equals sen[i] sen i "END_OF_TEXT" break; i++ i int ans=0; ans 0 int num=word.length(); num word.length() word.length word for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        } int j=0; int j=0; j 0 j<i+1 j i+1 i 1 j++ j++ j {
            if(sen[j].equalsIgnoreCase(word))ans++;
        } {
            if(sen[j].equalsIgnoreCase(word))ans++;
        } if(sen[j].equalsIgnoreCase(word))ans++; sen[j].equalsIgnoreCase(word) sen[j].equalsIgnoreCase sen[j] sen j word ans++ ans System.out.println(ans) System.out.println System.out System System.out ans return; String[] args args public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    }
} public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    }
} Main
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String word;
        String[] sen = new String[1000];
        int i=0;
        word = scan.next();
        while(true){
            sen[i] = scan.next();
            if(sen[i].equals("END_OF_TEXT"))break;
            i++; 
        }
        int ans=0;
        int num=word.length();;
        for(int j=0;j<i+1;j++){
            if(sen[j].equalsIgnoreCase(word))ans++;
        }
        System.out.println(ans);
        return;
    }
}
