import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine();
        int count = 0;
        String t;
        while (!((t = sc.next()).equals("END_OF_TEXT"))) {
            if(t.toLowerCase().equals(w))
                count++;
        }
        System.out.println(count);
    }
} import java.util.*; util.* java class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine();
        int count = 0;
        String t;
        while (!((t = sc.next()).equals("END_OF_TEXT"))) {
            if(t.toLowerCase().equals(w))
                count++;
        }
        System.out.println(count);
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine();
        int count = 0;
        String t;
        while (!((t = sc.next()).equals("END_OF_TEXT"))) {
            if(t.toLowerCase().equals(w))
                count++;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine();
        int count = 0;
        String t;
        while (!((t = sc.next()).equals("END_OF_TEXT"))) {
            if(t.toLowerCase().equals(w))
                count++;
        }
        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 int count = 0; count 0 String t; t while (!((t = sc.next()).equals("END_OF_TEXT"))) {
            if(t.toLowerCase().equals(w))
                count++;
        } !((t = sc.next()).equals("END_OF_TEXT")) ((t = sc.next()).equals("END_OF_TEXT")) (t = sc.next()).equals (t = sc.next()) t sc.next() sc.next sc "END_OF_TEXT" {
            if(t.toLowerCase().equals(w))
                count++;
        } if(t.toLowerCase().equals(w))
                count++; t.toLowerCase().equals(w) t.toLowerCase().equals t.toLowerCase() t.toLowerCase t w count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine();
        int count = 0;
        String t;
        while (!((t = sc.next()).equals("END_OF_TEXT"))) {
            if(t.toLowerCase().equals(w))
                count++;
        }
        System.out.println(count);
    }
}
