import java.util.Scanner;

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

        String W = sc.next();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    }
} 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();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String W = sc.next();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);

        String W = sc.next();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.next(); W sc.next() sc.next sc StringBuilder Wt = new StringBuilder(); Wt new StringBuilder() for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        } String s W.split("") W.split W "" {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        } {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        } Wt.append(Character.toLowerCase(s.charAt(0))) Wt.append Wt Character.toLowerCase(s.charAt(0)) Character.toLowerCase Character s.charAt(0) s.charAt s 0 int sum = 0; sum 0 while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        } true {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        } String T = sc.next(); T sc.next() sc.next sc if ("END_OF_TEXT".equals(T)) break; "END_OF_TEXT".equals(T) "END_OF_TEXT".equals "END_OF_TEXT" T break; StringBuilder tmp = new StringBuilder(); tmp new StringBuilder() for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            } String s T.split("") T.split T "" {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            } {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            } if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0))); Character.isLetter(s.charAt(0)) Character.isLetter Character s.charAt(0) s.charAt s 0 tmp.append(Character.toLowerCase(s.charAt(0))) tmp.append tmp Character.toLowerCase(s.charAt(0)) Character.toLowerCase Character s.charAt(0) s.charAt s 0 if (tmp.toString().equals(Wt.toString())) sum++; tmp.toString().equals(Wt.toString()) tmp.toString().equals tmp.toString() tmp.toString tmp Wt.toString() Wt.toString Wt sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String W = sc.next();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String W = sc.next();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    }
} Main
import java.util.Scanner;

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

        String W = sc.next();

        StringBuilder Wt = new StringBuilder();
        for (String s : W.split("")) {
            Wt.append(Character.toLowerCase(s.charAt(0)));
        }

        int sum = 0;
        while (true) {
            String T = sc.next();
            if ("END_OF_TEXT".equals(T)) break;

            StringBuilder tmp = new StringBuilder();
            for(String s : T.split("")) {
                if (Character.isLetter(s.charAt(0))) tmp.append(Character.toLowerCase(s.charAt(0)));
            }

            if (tmp.toString().equals(Wt.toString())) sum++;
        }
        System.out.println(sum);
    }
}