import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	}

} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	}

} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final String word = sc.next(); word sc.next() sc.next sc int count = 0; count 0 while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		} true {
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		} final String txt = sc.next(); txt sc.next() sc.next sc if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			} "END_OF_TEXT".equals(txt) "END_OF_TEXT".equals "END_OF_TEXT" txt {
				break;
			} break; if(word.equalsIgnoreCase(txt)){
				count++;
			} word.equalsIgnoreCase(txt) word.equalsIgnoreCase word txt {
				count++;
			} count++ count 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);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	}

} public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	}

} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final String word = sc.next();
		
		int count = 0;
		while(true){
			final String txt = sc.next();
			
			if("END_OF_TEXT".equals(txt)){
				break;
			}else if(word.equalsIgnoreCase(txt)){
				count++;
			}
		}
		
		System.out.println(count);
	}

}