import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    } main {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String w = scanner.next().toUpperCase(); w scanner.next().toUpperCase() scanner.next().toUpperCase scanner.next() scanner.next scanner String s = scanner.next(); s scanner.next() scanner.next scanner int count = 0; count 0 while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        } !s.equals("END_OF_TEXT") s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        } s = s.toUpperCase() s s.toUpperCase() s.toUpperCase s if (s.equals(w)) count++; s.equals(w) s.equals s w count++ count s = scanner.next() s scanner.next() scanner.next scanner System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.next().toUpperCase();
        String s = scanner.next();
        int count = 0;
        while (!s.equals("END_OF_TEXT")) {
            s = s.toUpperCase();
            if (s.equals(w)) count++;
            s = scanner.next();
        }
        System.out.println(count);
    }
} Main
import java.util.Scanner;

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