import java.util.Scanner;
 
class Main{
    	public static void main(String[] args){
        	Scanner sc = new Scanner(System.in);
        	String str = sc.nextLine().toLowerCase();
        	int x = 0;
        	while (sc.hasNextLine()) {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	}
        	System.out.println(x);
    	}
} import java.util.Scanner; Scanner java.util class Main{
    	public static void main(String[] args){
        	Scanner sc = new Scanner(System.in);
        	String str = sc.nextLine().toLowerCase();
        	int x = 0;
        	while (sc.hasNextLine()) {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	}
        	System.out.println(x);
    	}
} Main public static void main(String[] args){
        	Scanner sc = new Scanner(System.in);
        	String str = sc.nextLine().toLowerCase();
        	int x = 0;
        	while (sc.hasNextLine()) {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	}
        	System.out.println(x);
    	} main {
        	Scanner sc = new Scanner(System.in);
        	String str = sc.nextLine().toLowerCase();
        	int x = 0;
        	while (sc.hasNextLine()) {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	}
        	System.out.println(x);
    	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine().toLowerCase(); str sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int x = 0; x 0 while (sc.hasNextLine()) {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	} sc.hasNextLine() sc.hasNextLine sc {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	} String str2 = sc.nextLine(); str2 sc.nextLine() sc.nextLine sc if ("END_OF_TEXT".equals(str2)) {
                		break;
            		} "END_OF_TEXT".equals(str2) "END_OF_TEXT".equals "END_OF_TEXT" str2 {
                		break;
            		} break; String[] str3 = str2.split(" "); str3 str2.split(" ") str2.split str2 " " for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		} int i = 0, l = str3.length; int i = 0 i 0 l = str3.length; l str3.length str3 str3.length i < l i l i++ i++ i {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		} {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		} String s = str3[i]; s str3[i] str3 i if (s.toLowerCase().equals(str)) {
                    			x++;
                		} s.toLowerCase().equals(str) s.toLowerCase().equals s.toLowerCase() s.toLowerCase s str {
                    			x++;
                		} x++ x System.out.println(x) System.out.println System.out System System.out x String[] args args
import java.util.Scanner;
 
class Main{
    	public static void main(String[] args){
        	Scanner sc = new Scanner(System.in);
        	String str = sc.nextLine().toLowerCase();
        	int x = 0;
        	while (sc.hasNextLine()) {
            		String str2 = sc.nextLine();
            		if ("END_OF_TEXT".equals(str2)) {
                		break;
            		}
            		String[] str3 = str2.split(" ");
            		for (int i = 0, l = str3.length; i < l; i++) {
                		String s = str3[i];
                		if (s.toLowerCase().equals(str)) {
                    			x++;
                		}
            		}
        	}
        	System.out.println(x);
    	}
}