import java.util.*;

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

        while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        }
        System.out.println(count);

    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String W = scan.next();
        int count = 0;

        while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        }
        System.out.println(count);

    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String W = scan.next();
        int count = 0;

        while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        }
        System.out.println(count);

    } main {
        Scanner scan = new Scanner(System.in);
        String W = scan.next();
        int count = 0;

        while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        }
        System.out.println(count);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.next(); W scan.next() scan.next scan int count = 0; count 0 while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        } true {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        } String T = scan.next(); T scan.next() scan.next scan if (T.equals("END_OF_TEXT")) {
                break;
            } T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
                break;
            } break; if (T.equalsIgnoreCase(W)) {
                count++;
            } T.equalsIgnoreCase(W) T.equalsIgnoreCase T W {
                count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

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

        while (true) {
            String T = scan.next();
//            System.out.println(T);

            if (T.equals("END_OF_TEXT")) {
                break;
            }

            if (T.equalsIgnoreCase(W)) {
                count++;
            }
        }
        System.out.println(count);

    }
}