import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W = br.readLine(); W br.readLine() br.readLine br int count = 0; count 0 String str; str while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        } !(str = br.readLine()).equals("END_OF_TEXT") (str = br.readLine()).equals("END_OF_TEXT") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "END_OF_TEXT" {
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        } String str2[] = str.split(" "); str2 str.split(" ") str.split str " " for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            } String s str2 {
                if(s.equalsIgnoreCase(W)) count++;
            } {
                if(s.equalsIgnoreCase(W)) count++;
            } if(s.equalsIgnoreCase(W)) count++; s.equalsIgnoreCase(W) s.equalsIgnoreCase s W count++ count 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 W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String W = br.readLine();
        int count = 0;
        String str;
        while(!(str = br.readLine()).equals("END_OF_TEXT")){
            String str2[] = str.split(" ");
            for(String s:str2){
                if(s.equalsIgnoreCase(W)) count++;
            }
        }
        System.out.println(count);
    }
}