import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    } main {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> A = new ArrayList<String>(); A new ArrayList<String>() String str; str int count = 0; count 0 String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        } true {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        } str = sc.nextLine() str sc.nextLine() sc.nextLine sc if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            } str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            } while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                } A.contains(W) A.contains A W {
                    A.remove(A.indexOf(W));
                    count++;
                } A.remove(A.indexOf(W)) A.remove A A.indexOf(W) A.indexOf A W count++ count System.out.println(count) System.out.println System.out System System.out count break; str = str.toLowerCase() str str.toLowerCase() str.toLowerCase str String[] S = str.split(" "); S str.split(" ") str.split str " " for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            } int i=0; int i=0; i 0 i<S.length i S.length S S.length i++ i++ i {
                A.add(S[i]);
            } {
                A.add(S[i]);
            } A.add(S[i]) A.add A S[i] S i String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //StringBuilder bd = new StringBuilder();
        ArrayList<String> A = new ArrayList<String>();
        //int[] A = new int[26];
        //Arrays.fill(A, 0);
        String str;

        int count = 0;

        String W = sc.nextLine();

        while (true) {
            str = sc.nextLine();
            if (str.equals("END_OF_TEXT")) {
                while (A.contains(W)) {
                    A.remove(A.indexOf(W));
                    count++;
                }
                System.out.println(count);
                break;
            }
            str = str.toLowerCase();


            String[] S = str.split(" ");
            for (int i=0; i<S.length; i++) {
                A.add(S[i]);
            }
        }
        

    }
}
