import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    }
} Main public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str int count = 0; count 0 str = br.readLine() str br.readLine() br.readLine br String W = str.toLowerCase(); W str.toLowerCase() str.toLowerCase str while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } (str = br.readLine()) != null (str = br.readLine()) str br.readLine() br.readLine br null {
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } String x = str.toLowerCase(); x str.toLowerCase() str.toLowerCase str String[] temp = x.split("\\s"); temp x.split("\\s") x.split x "\\s" for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           } int i =0; int i =0; i 0 i<temp.length i temp.length temp temp.length i++ i++ i {
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           } {
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           } if(temp[i].equals("END_OF_TEXT")){
                    break;
                } temp[i].equals("END_OF_TEXT") temp[i].equals temp[i] temp i "END_OF_TEXT" {
                    break;
                } break; if(W.equals(temp[i])){
                   count++;
               } W.equals(temp[i]) W.equals W temp[i] temp i {
                   count++;
               } count++ count br.close() br.close br System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    }
} public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    }
} Main
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        int count = 0;

        str = br.readLine();
        String W = str.toLowerCase();
        while((str = br.readLine()) != null){
           String x = str.toLowerCase();
           String[] temp = x.split("\\s");
           for(int i =0;i<temp.length;i++){
                if(temp[i].equals("END_OF_TEXT")){
                    break;
                }
               if(W.equals(temp[i])){
                   count++;
               }
           }
        } 
        br.close();
        System.out.println(count);
    }
}