import java.util.Scanner;

class Main{
	public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
	
        String W = sc.nextLine();
        int count = 0;

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

	while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))
           break;
        
        	W= W.toUpperCase( );
        	T= T.toUpperCase( );
           if(T.equals(W))
           count++;
		}
           System.out.println(count);
	}
} Main public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
	
        String W = sc.nextLine();
        int count = 0;

	while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))
           break;
        
        	W= W.toUpperCase( );
        	T= T.toUpperCase( );
           if(T.equals(W))
           count++;
		}
           System.out.println(count);
	} main {
	Scanner sc = new Scanner(System.in);
	
        String W = sc.nextLine();
        int count = 0;

	while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))
           break;
        
        	W= W.toUpperCase( );
        	T= T.toUpperCase( );
           if(T.equals(W))
           count++;
		}
           System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc int count = 0; count 0 while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))
           break;
        
        	W= W.toUpperCase( );
        	T= T.toUpperCase( );
           if(T.equals(W))
           count++;
		} true {
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))
           break;
        
        	W= W.toUpperCase( );
        	T= T.toUpperCase( );
           if(T.equals(W))
           count++;
		} 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; W= W.toUpperCase( ) W W.toUpperCase( ) W.toUpperCase W T= T.toUpperCase( ) T T.toUpperCase( ) T.toUpperCase T if(T.equals(W))
           count++; T.equals(W) T.equals T W count++ count System.out.println(count) System.out.println System.out System System.out count String[]args args
import java.util.Scanner;

class Main{
	public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
	
        String W = sc.nextLine();
        int count = 0;

	while(true){
        String T = sc.next();
        if(T.equals("END_OF_TEXT"))
           break;
        
        	W= W.toUpperCase( );
        	T= T.toUpperCase( );
           if(T.equals(W))
           count++;
		}
           System.out.println(count);
	}
}
