import java.io.*;
import java.util.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String w = input.readLine();
        String t;
        int num = 0;
 
        while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        }
 
        System.out.println(num);
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String w = input.readLine();
        String t;
        int num = 0;
 
        while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        }
 
        System.out.println(num);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String w = input.readLine();
        String t;
        int num = 0;
 
        while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        }
 
        System.out.println(num);
    } main {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String w = input.readLine();
        String t;
        int num = 0;
 
        while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        }
 
        System.out.println(num);
    } BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) String w = input.readLine(); w input.readLine() input.readLine input String t; t int num = 0; num 0 while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        } !(t = input.readLine()).equals("END_OF_TEXT") (t = input.readLine()).equals("END_OF_TEXT") (t = input.readLine()).equals (t = input.readLine()) t input.readLine() input.readLine input "END_OF_TEXT" {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        } t = t.toLowerCase() t t.toLowerCase() t.toLowerCase t Scanner scan = new Scanner(t); scan new Scanner(t) while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            } scan.hasNext() scan.hasNext scan {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            } String str = scan.next(); str scan.next() scan.next scan if (str.equals(w))
                    num++; str.equals(w) str.equals str w num++ num System.out.println(num) System.out.println System.out System System.out num String[] args args
import java.io.*;
import java.util.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String w = input.readLine();
        String t;
        int num = 0;
 
        while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        }
 
        System.out.println(num);
    }
}