import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.BufferedWriter; BufferedWriter java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStreamWriter; OutputStreamWriter java.io import java.io.IOException; IOException java.io public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    }

} Main public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw new BufferedWriter(new OutputStreamWriter(System.out)) String T = br.readLine().toLowerCase(); T br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br int count = 0; count 0 String input; input while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        } !(input = br.readLine()).equals("END_OF_TEXT") (input = br.readLine()).equals("END_OF_TEXT") (input = br.readLine()).equals (input = br.readLine()) input br.readLine() br.readLine br "END_OF_TEXT" {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        } String[] word = input.toLowerCase().split(" "); word input.toLowerCase().split(" ") input.toLowerCase().split input.toLowerCase() input.toLowerCase input " " for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            } String w word {
                if (T.equals(w)) {
                    count++;
                }
            } {
                if (T.equals(w)) {
                    count++;
                }
            } if (T.equals(w)) {
                    count++;
                } T.equals(w) T.equals T w {
                    count++;
                } count++ count bw.append(count + "\n") bw.append bw count + "\n" count "\n" bw.flush() bw.flush bw String args[] args public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    }

} public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    }

} Main
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String T = br.readLine().toLowerCase();

        int count = 0;
        String input;
        while (!(input = br.readLine()).equals("END_OF_TEXT")) {
            String[] word = input.toLowerCase().split(" ");
            for (String w : word) {
                if (T.equals(w)) {
                    count++;
                }
            }
        }

        bw.append(count + "\n");
        bw.flush();
    }

}
