import java.util.*;

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

        String W = sc.nextLine();
        String T = "";
        String[] T_split;

        int count = 0;
        while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String W = sc.nextLine();
        String T = "";
        String[] T_split;

        int count = 0;
        while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String W = sc.nextLine();
        String T = "";
        String[] T_split;

        int count = 0;
        while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);

        String W = sc.nextLine();
        String T = "";
        String[] T_split;

        int count = 0;
        while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc String T = ""; T "" String[] T_split; T_split int count = 0; count 0 while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        } true {
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        } T = sc.nextLine() T sc.nextLine() sc.nextLine sc if(T.equals("END_OF_TEXT")) break;  //終了条件 T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break;  //終了条件 T_split = T.split(" ",0) T_split T.split(" ",0) T.split T " " 0 for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            } int i = 0; int i = 0; i 0 i < T_split.length i T_split.length T_split T_split.length i++ i++ i {
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            } {
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            } T_split[i] = T_split[i].toLowerCase() T_split[i] T_split i T_split[i].toLowerCase() T_split[i].toLowerCase T_split[i] T_split i if(T_split[i].matches(W))  count++; T_split[i].matches(W) T_split[i].matches T_split[i] T_split i W count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

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

        String W = sc.nextLine();
        String T = "";
        String[] T_split;

        int count = 0;
        while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        }
        System.out.println(count);
    }
}
