import java.util.Scanner;

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

public class Main {
    public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
        String W = sc.next();
        W = W.toLowerCase();
        String T[] = new String[10000];
        int count = 0;
        for(int i=0; i<10000; i++){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")) break;
            T[i] = T[i].toLowerCase();
            if(T[i].equals(W)) count++;
        } 
        System.out.println(count);
    }
}
