import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	}
} Main public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x = sc.nextLine().toLowerCase(); x sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc String line = ""; line "" while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		} true {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		} String tmp = sc.nextLine(); tmp sc.nextLine() sc.nextLine sc if(tmp.equals("END_OF_TEXT")) {
				break;
			} tmp.equals("END_OF_TEXT") tmp.equals tmp "END_OF_TEXT" {
				break;
			} break; line += " " + tmp line " " + tmp " " tmp int count = 0; count 0 if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		} line.toLowerCase().contains(x) line.toLowerCase().contains line.toLowerCase() line.toLowerCase line x {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		} String[] tmp = line.toLowerCase().split(" "); tmp line.toLowerCase().split(" ") line.toLowerCase().split line.toLowerCase() line.toLowerCase line " " for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			} int i=0; int i=0; i 0 i<tmp.length i tmp.length tmp tmp.length i++ i++ i {
				if(tmp[i].equals(x)) {
					count++;
				}
			} {
				if(tmp[i].equals(x)) {
					count++;
				}
			} if(tmp[i].equals(x)) {
					count++;
				} tmp[i].equals(x) tmp[i].equals tmp[i] tmp i x {
					count++;
				} 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) throws IOException{

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	}
} public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	}
} Main
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		String x = sc.nextLine().toLowerCase();
		String line = "";
		while(true) {
			String tmp = sc.nextLine();
			if(tmp.equals("END_OF_TEXT")) {
				break;
			}
			line += " " + tmp;
		}

		int count = 0;

		if(line.toLowerCase().contains(x)) {
			String[] tmp = line.toLowerCase().split(" ");
			for(int i=0;i<tmp.length;i++) {
				if(tmp[i].equals(x)) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	}
}
