import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	}

} import java.util.Scanner; Scanner java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc String T = ""; T "" String end = "END_OF_TEXT"; end "END_OF_TEXT" int ans = 0; ans 0 while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		} !(T.equals(end)) (T.equals(end)) T.equals T end {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		} T = sc.next() T sc.next() sc.next sc Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE); ptn Pattern.compile(W, Pattern.CASE_INSENSITIVE) Pattern.compile Pattern W Pattern.CASE_INSENSITIVE Pattern Pattern.CASE_INSENSITIVE Matcher mc = ptn.matcher(T); mc ptn.matcher(T) ptn.matcher ptn T if(mc.matches()){
				ans++;
			} mc.matches() mc.matches mc {
				ans++;
			} 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 sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	}

} Main
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String W = sc.nextLine();
		String T = "";
		String end = "END_OF_TEXT";


		int ans = 0;

		while (!(T.equals(end))) {
			T = sc.next();
			Pattern ptn = Pattern.compile(W, Pattern.CASE_INSENSITIVE);
			Matcher mc = ptn.matcher(T);
			if(mc.matches()){
				ans++;
			}
		}

		System.out.println(ans);
	}

}