import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine(); w sc.nextLine() sc.nextLine sc String t = ""; t "" int cnt = 0; cnt 0 w = w.toUpperCase() w w.toUpperCase() w.toUpperCase w while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		} !(t.equals("END_OF_TEXT")) (t.equals("END_OF_TEXT")) t.equals t "END_OF_TEXT" {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		} t = sc.next() t sc.next() sc.next sc if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			} !(t.equals("end_of_text")) (t.equals("end_of_text")) t.equals t "end_of_text" {
				t = t.toUpperCase();
			} t = t.toUpperCase() t t.toUpperCase() t.toUpperCase t String[] tTbl = t.split(" ", 0); tTbl t.split(" ", 0) t.split t " " 0 for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			} int i = 0; int i = 0; i 0 i < tTbl.length i tTbl.length tTbl tTbl.length i++ i++ i {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			} {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			} if(tTbl[i].equals(w)) {
					cnt++;
				} tTbl[i].equals(w) tTbl[i].equals tTbl[i] tTbl i w {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}