import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    }
    
    static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    }
} import java.util.HashMap; HashMap java.util import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util import java.util.regex.Pattern; Pattern java.util.regex import java.util.Collections; Collections java.util import java.math.BigDecimal; BigDecimal java.math public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    }
    
    static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    }
} Main public static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    } main {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    } String w = sc.next(); w sc.next() sc.next sc int res = 0; res 0 while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        } sc.hasNext() sc.hasNext sc {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        } String s = sc.next(); s sc.next() sc.next sc if (s.equals("END_OF_TEXT")) break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; if (isContain(s, w)) res++; isContain(s, w) isContain s w res++ res System.out.println(res) System.out.println System.out System System.out res String[] args args static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    } isContain {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    } s = s.toUpperCase() s s.toUpperCase() s.toUpperCase s w = w.toUpperCase() w w.toUpperCase() w.toUpperCase w return s.equals(w); s.equals(w) s.equals s w String s s String w w public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    }
    
    static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    }
} public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    }
    
    static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    }
} Main
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    }
    
    static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    }
}