import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		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();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc String t = sc.nextLine(); t sc.nextLine() sc.nextLine sc String T = t; T t while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		} true {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		} 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; T += " " + t T " " + t " " t int count = 0; count 0 int result = 0; result 0 T = " " + T.toLowerCase() + " " T " " + T.toLowerCase() + " " " " + T.toLowerCase() + " " " " T.toLowerCase() T.toLowerCase T " " while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		} true {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		} result = T.indexOf(" " + W + " ") result T.indexOf(" " + W + " ") T.indexOf T " " + W + " " " " + W + " " " " W " " if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			} result == -1 result -1 1 {
				break;
			} break; {
				count++;
				T = T.substring(result + W.length() + 1);
			} count++ count T = T.substring(result + W.length() + 1) T T.substring(result + W.length() + 1) T.substring T result + W.length() + 1 result + W.length() + 1 result W.length() W.length W 1 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();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.nextLine();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		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();
		String t = sc.nextLine();
		String T = t;
		while (true) {
			t = sc.nextLine();
			if (t.equals("END_OF_TEXT"))
				break;
			T += " " + t;
		}
		int count = 0;
		int result = 0;
		T = " " + T.toLowerCase() + " ";
		while (true) {
			result = T.indexOf(" " + W + " ");
			if (result == -1) {
				break;
			} else {
				count++;
				T = T.substring(result + W.length() + 1);
			}
		}
		System.out.println(count);
	}
}
