import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }

} 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().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine().toLowerCase(); w sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc StringBuilder sb = new StringBuilder(sc.nextLine()); sb new StringBuilder(sc.nextLine()) while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        } true {
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        } String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc if(s.equals("END_OF_TEXT")) break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; sb.append(" ").append(s) sb.append(" ").append sb.append(" ") sb.append sb " " s int cnt = 0; cnt 0 String[] str = sb.toString().toLowerCase().split(" "); str sb.toString().toLowerCase().split(" ") sb.toString().toLowerCase().split sb.toString().toLowerCase() sb.toString().toLowerCase sb.toString() sb.toString sb " " for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        } int i = 0,l = str.length; int i = 0 i 0 l = str.length; l str.length str str.length i < l i l ++i ++i i {
            if(str[i].equals(w)) ++cnt;
        } {
            if(str[i].equals(w)) ++cnt;
        } if(str[i].equals(w)) ++cnt; str[i].equals(w) str[i].equals str[i] str i w ++cnt cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }

} public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        StringBuilder sb = new StringBuilder(sc.nextLine());
        while(true){
            String s = sc.nextLine();
            if(s.equals("END_OF_TEXT")) break;
            sb.append(" ").append(s);
        }
        int cnt = 0;
        String[] str = sb.toString().toLowerCase().split(" ");
        for(int i = 0,l = str.length;i < l;++i){
            if(str[i].equals(w)) ++cnt;
        }
        System.out.println(cnt);
    }

}