import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    } main {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String W = stdIn.next().toLowerCase(); W stdIn.next().toLowerCase() stdIn.next().toLowerCase stdIn.next() stdIn.next stdIn stdIn.nextLine() stdIn.nextLine stdIn int answer = 0; answer 0 while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        } true {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        } String line = stdIn.nextLine(); line stdIn.nextLine() stdIn.nextLine stdIn if(line.equals("END_OF_TEXT")) {
                break;
            } line.equals("END_OF_TEXT") line.equals line "END_OF_TEXT" {
                break;
            } break; for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            } String word line.toLowerCase().split(" ") line.toLowerCase().split line.toLowerCase() line.toLowerCase line " " {
                if(word.equals(W)) {
                    answer++;
                }
            } {
                if(word.equals(W)) {
                    answer++;
                }
            } if(word.equals(W)) {
                    answer++;
                } word.equals(W) word.equals word W {
                    answer++;
                } answer++ answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
}
