import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	}

} Main public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	} main {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	} @SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.nextLine().toLowerCase(); W scan.nextLine().toLowerCase() scan.nextLine().toLowerCase scan.nextLine() scan.nextLine scan int ans = 0; ans 0 while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		} scan.hasNext() scan.hasNext scan {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		} String t = scan.next(); t scan.next() scan.next scan if (t.equals("END_OF_TEXT"))
				break; t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" break; t=t.toLowerCase() t t.toLowerCase() t.toLowerCase t if (t.equals(W))
				ans++; t.equals(W) t.equals t W ans++ ans System.out.println(ans) System.out.println System.out System System.out ans System.exit(0) System.exit System 0 String[] args args public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	}

} public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String W = scan.nextLine().toLowerCase();
		int ans = 0;
		while (scan.hasNext()) {
			String t = scan.next();
			if (t.equals("END_OF_TEXT"))
				break;
			t=t.toLowerCase();
			if (t.equals(W))
				ans++;
		}
		System.out.println(ans);
		System.exit(0);
	}

}