import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.next().toLowerCase(); w sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc int count = 0; count 0 String word = sc.next(); word sc.next() sc.next sc for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		} ; !word.equals("END_OF_TEXT") word.equals("END_OF_TEXT") word.equals word "END_OF_TEXT" word = sc.next() word = sc.next() word sc.next() sc.next sc {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		} {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		} if (w.equals(word.toLowerCase())) {
				count++;
			} w.equals(word.toLowerCase()) w.equals w word.toLowerCase() word.toLowerCase word {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		String w = sc.next().toLowerCase();
		int count = 0;

		String word = sc.next();
		for (; !word.equals("END_OF_TEXT"); word = sc.next()) {
//			System.out.println(word);
			if (w.equals(word.toLowerCase())) {
				count++;
			}
		}

		System.out.println(count);
		
		sc.close();
	}
}