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 END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(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 END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(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 END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W = br.readLine().toLowerCase();
		String END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(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 END = "END_OF_TEXT"; END "END_OF_TEXT" int cnt = 0; cnt 0 for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			}
		} ; {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			}
		} {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			}
		} String line = br.readLine(); line br.readLine() br.readLine br if(line.equals(END)) {
				break;
			} line.equals(END) line.equals line END {
				break;
			} break; String[] words = line.split(" "); words line.split(" ") line.split line " " for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			} int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			} {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			} if(words[i].toLowerCase().equals(W)) {
					cnt++;
				} words[i].toLowerCase().equals(W) words[i].toLowerCase().equals words[i].toLowerCase() words[i].toLowerCase words[i] words i W {
					cnt++;
				} 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 END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(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 END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(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 END = "END_OF_TEXT";
		int cnt = 0;
		for(;;) {
			String line = br.readLine();
			if(line.equals(END)) {
				break;
			}
			String[] words = line.split(" ");
			for(int i = 0; i < words.length; i++) {
				if(words[i].toLowerCase().equals(W)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}