import java.util.Scanner;

public class Main {

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

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    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 s1 = sc.nextLine();

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s1 = sc.nextLine(); s1 sc.nextLine() sc.nextLine sc int count = 0; count 0 while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        } true {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        } String s2 = sc.nextLine(); s2 sc.nextLine() sc.nextLine sc if(s2.equals("END_OF_TEXT")) {
                break;
            } s2.equals("END_OF_TEXT") s2.equals s2 "END_OF_TEXT" {
                break;
            } break; String[] ss = s2.split(" "); ss s2.split(" ") s2.split s2 " " for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            } String s ss {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            } {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            } String s3 = s.toLowerCase(); s3 s.toLowerCase() s.toLowerCase s if(s3.equals(s1)) {
                    count++;
                } s3.equals(s1) s3.equals s3 s1 {
                    count++;
                } 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 s1 = sc.nextLine();

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} public class Main {

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

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    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 s1 = sc.nextLine();

        int count = 0;
        while(true) {
            String s2 = sc.nextLine();
            if(s2.equals("END_OF_TEXT")) {
                break;
            }
            String[] ss = s2.split(" ");
            for(String s : ss) {
                String s3 = s.toLowerCase();
                if(s3.equals(s1)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}
