import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	} main {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String word = sc.nextLine().toLowerCase(); word sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int count = 0; count 0 while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		} true {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		} String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc if(input.equals("END_OF_TEXT")) break; input.equals("END_OF_TEXT") input.equals input "END_OF_TEXT" break; String tmp = input.toLowerCase(); tmp input.toLowerCase() input.toLowerCase input String[] tangos = tmp.split(" "); tangos tmp.split(" ") tmp.split tmp " " for(String tango : tangos) {
				if(tango.equals(word)) count++;
			} String tango tangos {
				if(tango.equals(word)) count++;
			} {
				if(tango.equals(word)) count++;
			} if(tango.equals(word)) count++; tango.equals(word) tango.equals tango word count++ count sc.close() sc.close sc System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String word = sc.nextLine().toLowerCase();

		int count = 0;
		while(true) {

			String input = sc.nextLine();

			if(input.equals("END_OF_TEXT")) break;

			String tmp = input.toLowerCase();

			String[] tangos = tmp.split(" ");

			for(String tango : tangos) {
				if(tango.equals(word)) count++;
			}

		}
		sc.close();

		System.out.println(count);

	}
}