import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		final String key = br.readLine();
		int count = 0;
		loop:
		while(true){
			final String[] strs = br.readLine().split(" ");
			for(int i = 0; i < strs.length; i++){
			    final String str = strs[i];
				if(str.equals("END_OF_TEXT")){
					break loop;
				} else if(str.equalsIgnoreCase(key)){
					count++; 
				}
			}
		}
		System.out.println(count);
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws IOException {
		final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		final String key = br.readLine();
		int count = 0;
		loop:
		while(true){
			final String[] strs = br.readLine().split(" ");
			for(int i = 0; i < strs.length; i++){
			    final String str = strs[i];
				if(str.equals("END_OF_TEXT")){
					break loop;
				} else if(str.equalsIgnoreCase(key)){
					count++; 
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		final String key = br.readLine();
		int count = 0;
		loop:
		while(true){
			final String[] strs = br.readLine().split(" ");
			for(int i = 0; i < strs.length; i++){
			    final String str = strs[i];
				if(str.equals("END_OF_TEXT")){
					break loop;
				} else if(str.equalsIgnoreCase(key)){
					count++; 
				}
			}
		}
		System.out.println(count);
	} main {
		final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		final String key = br.readLine();
		int count = 0;
		loop:
		while(true){
			final String[] strs = br.readLine().split(" ");
			for(int i = 0; i < strs.length; i++){
			    final String str = strs[i];
				if(str.equals("END_OF_TEXT")){
					break loop;
				} else if(str.equalsIgnoreCase(key)){
					count++; 
				}
			}
		}
		System.out.println(count);
	} final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) final String key = br.readLine(); key br.readLine() br.readLine br int count = 0; count 0 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		final String key = br.readLine();
		int count = 0;
		loop:
		while(true){
			final String[] strs = br.readLine().split(" ");
			for(int i = 0; i < strs.length; i++){
			    final String str = strs[i];
				if(str.equals("END_OF_TEXT")){
					break loop;
				} else if(str.equalsIgnoreCase(key)){
					count++; 
				}
			}
		}
		System.out.println(count);
	}
}