import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        System.out.println(count);
    }    
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        System.out.println(count);
    }    
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        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 T = new String[1000] T new String[1000] 1000 int i = 0; i 0 int count = 0; count 0 while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        } true {
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        } T[i] = sc.next() T[i] T i sc.next() sc.next sc if(T[i].equals("END_OF_TEXT")){
                break;
            } T[i].equals("END_OF_TEXT") T[i].equals T[i] T i "END_OF_TEXT" {
                break;
            } break; if(T[i].equalsIgnoreCase(W)){
                count++;
            } T[i].equalsIgnoreCase(W) T[i].equalsIgnoreCase T[i] T i W {
                count++;
            } count++ count i++ i 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){
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        System.out.println(count);
    }    
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        System.out.println(count);
    }    
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String W = sc.nextLine();
        String[] T;
        T = new String[1000];
        int i = 0;
        int count = 0;
        while(true){
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            if(T[i].equalsIgnoreCase(W)){
                count++;
            }
            i++;
        }
        System.out.println(count);
    }    
}
