import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = 0 count 0 a a b; b String w w t; t w = sc.next().toLowerCase() w sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc a = w.length() a w.length() w.length w while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        } true {
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        } t = sc.next() t sc.next() sc.next sc b = t.length() b t.length() t.length t if(t.contains("END_OF_TEXT")) break; t.contains("END_OF_TEXT") t.contains t "END_OF_TEXT" break; if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	} a == b a b {
        		if(t.toLowerCase().contains(w)) count++;
        	} if(t.toLowerCase().contains(w)) count++; t.toLowerCase().contains(w) t.toLowerCase().contains t.toLowerCase() t.toLowerCase t w count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    }
} public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0, a, b;
        String w, t;
        w = sc.next().toLowerCase();
        a = w.length();
        while(true){
        	t = sc.next();
        	b = t.length();
        	if(t.contains("END_OF_TEXT")) break;
        	if(a == b) {
        		if(t.toLowerCase().contains(w)) count++;
        	}
        }
        System.out.println(count);
        sc.close();
    }
}
