import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	}
}
 import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc W = W.toLowerCase() W W.toLowerCase() W.toLowerCase W List<String> T = new ArrayList<String>(); T new ArrayList<String>() String line = sc.next(); line sc.next() sc.next sc while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		} !"END_OF_TEXT".equals(line) "END_OF_TEXT".equals(line) "END_OF_TEXT".equals "END_OF_TEXT" line {
			T.add(line.toLowerCase());
			line = sc.next();
		} T.add(line.toLowerCase()) T.add T line.toLowerCase() line.toLowerCase line line = sc.next() line sc.next() sc.next sc int cnt = 0; cnt 0 for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		} int i = 0; int i = 0; i 0 i < T.size() i T.size() T.size T i++ i++ i {
			if (T.get(i).equals(W)) cnt++;
		} {
			if (T.get(i).equals(W)) cnt++;
		} if (T.get(i).equals(W)) cnt++; T.get(i).equals(W) T.get(i).equals T.get(i) T.get T i 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 Exception {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		String W = sc.nextLine();
		W = W.toLowerCase();
		
		List<String> T = new ArrayList<String>();

		String line = sc.next();
		while (!"END_OF_TEXT".equals(line)) {
			T.add(line.toLowerCase());
			line = sc.next();
		}
		int cnt = 0;
		for (int i = 0; i < T.size(); i++) {
			if (T.get(i).equals(W)) cnt++;
		}
		System.out.println(cnt);
	}
}

