import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine().toLowerCase();
        String str;
        String[] strArr;
        int count = 0;
        int i;
        while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} import java.io.*; io.* java class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine().toLowerCase();
        String str;
        String[] strArr;
        int count = 0;
        int i;
        while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine().toLowerCase();
        String str;
        String[] strArr;
        int count = 0;
        int i;
        while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine().toLowerCase();
        String str;
        String[] strArr;
        int count = 0;
        int i;
        while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String target = br.readLine().toLowerCase(); target br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br String str; str String[] strArr; strArr int count = 0; count 0 int i; i while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        } !(str = br.readLine()).equals("END_OF_TEXT") (str = br.readLine()).equals("END_OF_TEXT") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "END_OF_TEXT" {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        } strArr = str.toLowerCase().split(" ") strArr str.toLowerCase().split(" ") str.toLowerCase().split str.toLowerCase() str.toLowerCase str " " for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            } i = 0; i = 0 i 0 i < strArr.length i strArr.length strArr strArr.length i++ i++ i {
                if (strArr[i].equals(target)) {
                    count++;
                }
            } {
                if (strArr[i].equals(target)) {
                    count++;
                }
            } if (strArr[i].equals(target)) {
                    count++;
                } strArr[i].equals(target) strArr[i].equals strArr[i] strArr i target {
                    count++;
                } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine().toLowerCase();
        String str;
        String[] strArr;
        int count = 0;
        int i;
        while (!(str = br.readLine()).equals("END_OF_TEXT")) {
            strArr = str.toLowerCase().split(" ");
            for (i = 0; i < strArr.length; i++) {
                if (strArr[i].equals(target)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}