import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=0;
		String d = sc.nextLine();
		while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		}
		System.out.println(count);

	}
} import java.io.*; io.* java import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=0;
		String d = sc.nextLine();
		while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		}
		System.out.println(count);

	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=0;
		String d = sc.nextLine();
		while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		}
		System.out.println(count);

	} main {
		Scanner sc=new Scanner(System.in);
		int count=0;
		String d = sc.nextLine();
		while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		}
		System.out.println(count);

	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int count=0; count 0 String d = sc.nextLine(); d sc.nextLine() sc.nextLine sc while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		} true {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		} String a = sc.nextLine(); a sc.nextLine() sc.nextLine sc if (a.equals("END_OF_TEXT"))break; a.equals("END_OF_TEXT") a.equals a "END_OF_TEXT" break; for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			} String s a.split(" ") a.split a " " {
				if (s.equalsIgnoreCase(d))
					count++;
			} {
				if (s.equalsIgnoreCase(d))
					count++;
			} if (s.equalsIgnoreCase(d))
					count++; s.equalsIgnoreCase(d) s.equalsIgnoreCase s d count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int count=0;
		String d = sc.nextLine();
		while (true) {
			String a = sc.nextLine();
			if (a.equals("END_OF_TEXT"))break;
			for (String s : a.split(" ")) {
				if (s.equalsIgnoreCase(d))
					count++;
			}
		}
		System.out.println(count);

	}
}