import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String w = br.readLine().toLowerCase(); w br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br String[ ] tList = new String[10]; tList new String[10] 10 int cnt = 0; cnt 0 String t; t while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		} !(t = br.readLine()).equals("END_OF_TEXT") (t = br.readLine()).equals("END_OF_TEXT") (t = br.readLine()).equals (t = br.readLine()) t br.readLine() br.readLine br "END_OF_TEXT" {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		} tList = t.split(" ") tList t.split(" ") t.split t " " for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			} String target tList {
				if (target.equalsIgnoreCase(w)) cnt++;
			} {
				if (target.equalsIgnoreCase(w)) cnt++;
			} if (target.equalsIgnoreCase(w)) cnt++; target.equalsIgnoreCase(w) target.equalsIgnoreCase target w cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	}
} public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine().toLowerCase();
		String[ ] tList = new String[10];
		int cnt = 0;
		String t;
		while (!(t = br.readLine()).equals("END_OF_TEXT")) {
			tList = t.split(" ");
			for (String target : tList) {
				if (target.equalsIgnoreCase(w)) cnt++;
			}
		}
		System.out.println(cnt);
	}
}