import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    }

} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    }

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    } main {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s1 = new String(sc.nextLine()); s1 new String(sc.nextLine()) String s2 = new String(); s2 new String() int c=0; c 0 while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        } true {
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        } s2 = sc.next() s2 sc.next() sc.next sc if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	} s2.equals("END_OF_TEXT") s2.equals s2 "END_OF_TEXT" {
        		sc.close();
        		break;
        	} sc.close() sc.close sc break; if(s2.equalsIgnoreCase(s1)){
        		c++;
        	} s2.equalsIgnoreCase(s1) s2.equalsIgnoreCase s2 s1 {
        		c++;
        	} c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    }

} public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    }

} Main
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s1 = new String(sc.nextLine());
        String s2 = new String();
        int c=0;
        
        while(true){
        	s2 = sc.next();
        	if(s2.equals("END_OF_TEXT")){
        		sc.close();
        		break;
        	}
        	if(s2.equalsIgnoreCase(s1)){
        		c++;
        	}
        }
        System.out.println(c);
    }

}
