import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
           
             String Key = sc.next();
        		Key = Key.toUpperCase();
        int sum =0;
        while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        }
        System.out.println(sum);
        sc.close();
    }
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
           
             String Key = sc.next();
        		Key = Key.toUpperCase();
        int sum =0;
        while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        }
        System.out.println(sum);
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
           
             String Key = sc.next();
        		Key = Key.toUpperCase();
        int sum =0;
        while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        }
        System.out.println(sum);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
           
             String Key = sc.next();
        		Key = Key.toUpperCase();
        int sum =0;
        while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        }
        System.out.println(sum);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String Key = sc.next(); Key sc.next() sc.next sc Key = Key.toUpperCase() Key Key.toUpperCase() Key.toUpperCase Key int sum =0; sum 0 while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        } true {
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        } String T = sc.next(); T sc.next() sc.next sc if( T.equals( "END_OF_TEXT" ) )
                break; T.equals( "END_OF_TEXT" ) T.equals T "END_OF_TEXT" break; T = T.toUpperCase() T T.toUpperCase() T.toUpperCase T if(Key.equals(T))
                    sum++; Key.equals(T) Key.equals Key T sum++ sum System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
           
             String Key = sc.next();
        		Key = Key.toUpperCase();
        int sum =0;
        while( true ){
            String T = sc.next();
            if( T.equals( "END_OF_TEXT" ) )
                break;
				T = T.toUpperCase();
            	if(Key.equals(T))
                    sum++;
        }
        System.out.println(sum);
        sc.close();
    }
}
