import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		int sum = 0;

		while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		}

		System.out.println(sum);
	}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		int sum = 0;

		while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		}

		System.out.println(sum);
	}
} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		int sum = 0;

		while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		}

		System.out.println(sum);
	} main {
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		int sum = 0;

		while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		}

		System.out.println(sum);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String w = scanner.next(); w scanner.next() scanner.next scanner int sum = 0; sum 0 while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		} true {
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		} String x = scanner.next(); x scanner.next() scanner.next scanner if(x.equals("END_OF_TEXT")){
				break;
			} x.equals("END_OF_TEXT") x.equals x "END_OF_TEXT" {
				break;
			} break; if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			} x.toLowerCase().equals(w.toLowerCase()) x.toLowerCase().equals x.toLowerCase() x.toLowerCase x w.toLowerCase() w.toLowerCase w {
				sum++;
			} sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		int sum = 0;

		while(true){
			String x = scanner.next();

			if(x.equals("END_OF_TEXT")){
				break;
			}

			if(x.toLowerCase().equals(w.toLowerCase())){
				sum++;
			}
		}

		System.out.println(sum);
	}
}