import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String word = sc.next().toLowerCase();
		int c = 0;
		
		while (true) {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		}
		
		System.out.println(c);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String word = sc.next().toLowerCase();
		int c = 0;
		
		while (true) {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		}
		
		System.out.println(c);
	}
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String word = sc.next().toLowerCase();
		int c = 0;
		
		while (true) {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		}
		
		System.out.println(c);
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		String word = sc.next().toLowerCase();
		int c = 0;
		
		while (true) {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		}
		
		System.out.println(c);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String word = sc.next().toLowerCase(); word sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc int c = 0; c 0 while (true) {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		} true {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		} String key = sc.next(); key sc.next() sc.next sc if(key.equals("END_OF_TEXT")) break; key.equals("END_OF_TEXT") key.equals key "END_OF_TEXT" break; if(word.equals(key.toLowerCase())) c++; word.equals(key.toLowerCase()) word.equals word key.toLowerCase() key.toLowerCase key c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String word = sc.next().toLowerCase();
		int c = 0;
		
		while (true) {
			String key = sc.next();
			if(key.equals("END_OF_TEXT")) break;
			if(word.equals(key.toLowerCase())) c++;
			
		}
		
		System.out.println(c);
	}
}
