import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}



 import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    } solve {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    } String W =  sc.nextLine().toLowerCase(); W sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int cnt = 0; cnt 0 while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        } true {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        } String[] arr = sc.nextLine().split(" "); arr sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " if (arr[0].equals("END_OF_TEXT")) break; arr[0].equals("END_OF_TEXT") arr[0].equals arr[0] arr 0 "END_OF_TEXT" break; for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            } int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length ++i ++i i {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            } {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            } if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                } arr[i].toLowerCase().equals(W) arr[i].toLowerCase().equals arr[i].toLowerCase() arr[i].toLowerCase arr[i] arr i W {
                    cnt++;
                } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String W =  sc.nextLine().toLowerCase();
        int cnt = 0;
        while (true) {
            String[] arr = sc.nextLine().split(" ");
            if (arr[0].equals("END_OF_TEXT")) break;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i].toLowerCase().equals(W)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}




