import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String w = scanner.nextLine(); w scanner.nextLine() scanner.nextLine scanner StringBuilder t = new StringBuilder(); t new StringBuilder() while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        } true {
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        } String input = scanner.nextLine(); input scanner.nextLine() scanner.nextLine scanner if(input.equals("END_OF_TEXT")){
                break;
            } input.equals("END_OF_TEXT") input.equals input "END_OF_TEXT" {
                break;
            } break; t.append(input) t.append t input t.append(" ") t.append t " " String text = t.toString().toLowerCase(); text t.toString().toLowerCase() t.toString().toLowerCase t.toString() t.toString t String[] textArray = text.split("\\s+"); textArray text.split("\\s+") text.split text "\\s+" int count = 0; count 0 for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        } String txt textArray {
            if(txt.equals(w)){
                count++;
            }
        } {
            if(txt.equals(w)){
                count++;
            }
        } if(txt.equals(w)){
                count++;
            } txt.equals(w) txt.equals txt w {
                count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
} public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String w = scanner.nextLine();
        StringBuilder t = new StringBuilder();

        while(true){
            String input = scanner.nextLine();

            if(input.equals("END_OF_TEXT")){
                break;
            }

            t.append(input);
            t.append(" ");
        }

        String text = t.toString().toLowerCase();
        String[] textArray = text.split("\\s+");
        int count = 0;
        for(String txt : textArray){
            if(txt.equals(w)){
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
}

