import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        }
} import java.util.*; util.* java class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        }
} Main public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        } main {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        } try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                } {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) String S = sc.next().toUpperCase(); S sc.next().toUpperCase() sc.next().toUpperCase sc.next() sc.next sc int ans = 0; ans 0 while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        } true {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        } String T = sc.next(); T sc.next() sc.next sc if(T.equals("END_OF_TEXT"))break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; if (S.equals(T.toUpperCase())) {
                                        ans++;
                                } S.equals(T.toUpperCase()) S.equals S T.toUpperCase() T.toUpperCase T {
                                        ans++;
                                } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        }
}