import 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();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} import java.io.*; io.* java public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String w = br.readLine();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(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();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        }
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String w = br.readLine();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(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 String t = ""; t "" int count = 0; count 0 while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        } !(t = br.readLine()).equals("END_OF_TEXT") (t = br.readLine()).equals("END_OF_TEXT") (t = br.readLine()).equals (t = br.readLine()) t br.readLine() br.readLine br "END_OF_TEXT" {
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        } t = t.toLowerCase() t t.toLowerCase() t.toLowerCase t String[] words = t.split(" "); words t.split(" ") t.split t " " for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            } int i=0; int i=0; i 0 i < words.length i words.length words words.length i++ i++ i {
                if(words[i].equals(w)){
                    count++;
                }
            } {
                if(words[i].equals(w)){
                    count++;
                }
            } if(words[i].equals(w)){
                    count++;
                } words[i].equals(w) words[i].equals words[i] words i w {
                    count++;
                } 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();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(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();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} Main
import 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();
        String t = "";
        int count = 0;
        while(!(t = br.readLine()).equals("END_OF_TEXT")){
            t = t.toLowerCase();
            String[] words = t.split(" ");
            for(int i=0; i < words.length; i++){
                if(words[i].equals(w)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}