import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        String W = scan.nextLine();
        int count = 0;
        String T;
        while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        }
            System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        String W = scan.nextLine();
        int count = 0;
        String T;
        while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        }
            System.out.println(count);
    }
} Main public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        String W = scan.nextLine();
        int count = 0;
        String T;
        while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        }
            System.out.println(count);
    } main {
        Scanner scan = new Scanner(System.in);

        String W = scan.nextLine();
        int count = 0;
        String T;
        while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        }
            System.out.println(count);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.nextLine(); W scan.nextLine() scan.nextLine scan int count = 0; count 0 String T; T while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        } (T = scan.nextLine()) != null (T = scan.nextLine()) T scan.nextLine() scan.nextLine scan null {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        } if (T.equals("END_OF_TEXT")) {
                break;
            } T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
                break;
            } break; String[] str = T.split(" "); str T.split(" ") T.split T " " for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            } int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            } {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            } if(str[i].equalsIgnoreCase(W)) {
                    count++;
                } str[i].equalsIgnoreCase(W) str[i].equalsIgnoreCase str[i] str i W {
                    count++;
                } 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 scan = new Scanner(System.in);

        String W = scan.nextLine();
        int count = 0;
        String T;
        while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        }
            System.out.println(count);
    }
}