import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	}

} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	} main {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	} Integer count = 0; count 0 Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in))); s new Scanner(new BufferedReader(new InputStreamReader(System.in))) String word = s.next().toLowerCase(); word s.next().toLowerCase() s.next().toLowerCase s.next() s.next s while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		} s.hasNext() s.hasNext s {
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		} String input = s.next(); input s.next() s.next s if(input.equals("END_OF_TEXT")){
				break;
			} input.equals("END_OF_TEXT") input.equals input "END_OF_TEXT" {
				break;
			} break; String[] word_list = input.split(" "); word_list input.split(" ") input.split input " " for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			} int i = 0; int i = 0; i 0 i < word_list.length i word_list.length word_list word_list.length i++ i++ i {
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			} {
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			} String target = word_list[i].toLowerCase(); target word_list[i].toLowerCase() word_list[i].toLowerCase word_list[i] word_list i if(word.equals(target)){
					count++;
				} word.equals(target) word.equals word target {
					count++;
				} count++ count s.close() s.close s System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	}

} public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	}

} Main
import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer count = 0;
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String word = s.next().toLowerCase();
		while(s.hasNext()){
			String input = s.next();
			if(input.equals("END_OF_TEXT")){
				break;
			}
			String[] word_list = input.split(" ");
			for(int i = 0; i < word_list.length; i++){
				String target = word_list[i].toLowerCase();
				if(word.equals(target)){
					count++;
				}
			}
		}
		s.close();
		System.out.println(count);

	}

}