import java.io.*;
import java.util.*;
 
public class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    }
} Main /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    } main {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    } Integer count = 0; count 0 Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); s new Scanner(new BufferedReader(new InputStreamReader(System.in))) String word = s.next().toLowerCase(); word s.next().toLowerCase() s.next().toLowerCase s.next() s.next s while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        } s.hasNext() s.hasNext s {
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        } String input = s.next(); input s.next() s.next s if(input.equals("END_OF_TEXT")){
                break;
            } input.equals("END_OF_TEXT") input.equals input "END_OF_TEXT" {
                break;
            } break; if(word.equals(input.toLowerCase())){
                count++;
            } word.equals(input.toLowerCase()) word.equals word input.toLowerCase() input.toLowerCase input {
                count++;
            } count++ count s.close() s.close s System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    }
} public class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    }
} Main
import java.io.*;
import java.util.*;
 
public class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Integer count = 0;
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String word = s.next().toLowerCase();
        while(s.hasNext()){
            String input = s.next();
            if(input.equals("END_OF_TEXT")){
                break;
            }
            if(word.equals(input.toLowerCase())){
                count++;
            }
        }
        s.close();
        System.out.println(count);
    }
}