import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    } main {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String needle = sc.nextLine().toLowerCase(); needle sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int c = 0; c 0 while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        } sc.hasNextLine() sc.hasNextLine sc {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        } String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc if ("END_OF_TEXT".equals(line)) {
                break;
            } "END_OF_TEXT".equals(line) "END_OF_TEXT".equals "END_OF_TEXT" line {
                break;
            } break; String[] hashstack = line.split(" "); hashstack line.split(" ") line.split line " " for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            } int i = 0, l = hashstack.length; int i = 0 i 0 l = hashstack.length; l hashstack.length hashstack hashstack.length i < l i l i++ i++ i {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            } {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            } String s = hashstack[i]; s hashstack[i] hashstack i if (s.toLowerCase().equals(needle)) {
                    c++;
                } s.toLowerCase().equals(needle) s.toLowerCase().equals s.toLowerCase() s.toLowerCase s needle {
                    c++;
                } c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String needle = sc.nextLine().toLowerCase();
        int c = 0;
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            if ("END_OF_TEXT".equals(line)) {
                break;
            }
            String[] hashstack = line.split(" ");
            for (int i = 0, l = hashstack.length; i < l; i++) {
                String s = hashstack[i];
                if (s.toLowerCase().equals(needle)) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
}