import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    }
} Main public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine().toLowerCase(); w sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int count = 0; count 0 while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        } true {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        } String t = sc.nextLine(); t sc.nextLine() sc.nextLine sc if(t.equals("END_OF_TEXT")) {
        		break;
        	} t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" {
        		break;
        	} break; t = t.toLowerCase() t t.toLowerCase() t.toLowerCase t String[] wordArray = t.split(" "); wordArray t.split(" ") t.split t " " for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	} String word wordArray {
        		if(w.equals(word)) {
        			count++;
        		}
        	} {
        		if(w.equals(word)) {
        			count++;
        		}
        	} if(w.equals(word)) {
        			count++;
        		} w.equals(word) w.equals w word {
        			count++;
        		} count++ count 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 sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.nextLine().toLowerCase();
        int count = 0;

        while(true) {
        	String t = sc.nextLine();
        	if(t.equals("END_OF_TEXT")) {
        		break;
        	}
        	t = t.toLowerCase();

        	String[] wordArray = t.split(" ");
        	for(String word : wordArray) {
        		if(w.equals(word)) {
        			count++;
        		}
        	}
        }
        System.out.println(count);
    }
}
