import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	} main {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String W = in.nextLine(); W in.nextLine() in.nextLine in W = W.toLowerCase() W W.toLowerCase() W.toLowerCase W int ans = 0; ans 0 while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		} in.hasNext() in.hasNext in {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		} String s = in.nextLine(); s in.nextLine() in.nextLine in if(s.equals("END_OF_TEXT")) break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; s = s.toLowerCase() s s.toLowerCase() s.toLowerCase s String sp[] = s.split(" "); sp s.split(" ") s.split s " " for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			} int i=0; int i=0; i 0 i<sp.length i sp.length sp sp.length i++ i++ i {
				if(sp[i].equals(W)) ans++;
			} {
				if(sp[i].equals(W)) ans++;
			} if(sp[i].equals(W)) ans++; sp[i].equals(W) sp[i].equals sp[i] sp i W ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String W = in.nextLine();
		W = W.toLowerCase();
		int ans = 0;
		while(in.hasNext()) {
			String s = in.nextLine();
			if(s.equals("END_OF_TEXT")) break;
			s = s.toLowerCase();
			String sp[] = s.split(" ");
			for(int i=0;i<sp.length;i++) {
				if(sp[i].equals(W)) ans++;
			}
		}
		System.out.println(ans);
	}
}