import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    }
} Main public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    } main {
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String words words sentence; sentence words = scan.next().toUpperCase() words scan.next().toUpperCase() scan.next().toUpperCase scan.next() scan.next scan sentence = scan.next() sentence scan.next() scan.next scan int result=0; result 0 while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        } !sentence.equals("END_OF_TEXT") sentence.equals("END_OF_TEXT") sentence.equals sentence "END_OF_TEXT" {
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        } if(sentence.toUpperCase().equals(words))
                result++; sentence.toUpperCase().equals(words) sentence.toUpperCase().equals sentence.toUpperCase() sentence.toUpperCase sentence words result++ result sentence=scan.next() sentence scan.next() scan.next scan System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words, sentence;
        words = scan.next().toUpperCase();
        sentence = scan.next();
        int result=0;
        
        while(!sentence.equals("END_OF_TEXT")){
            if(sentence.toUpperCase().equals(words))
                result++;
            sentence=scan.next();
        }
        
            System.out.println(result);
    }
}
