import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		}

	public static void main(String[] args) {
	
		new Main().run();
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		}

	public static void main(String[] args) {
	
		new Main().run();
		
	}
} Main void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		} run {
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		} Scanner s = new Scanner(System.in); s new Scanner(System.in) String W = s.next(); W s.next() s.next s int count = 0; count 0 while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		} true {
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		} String T = s.next(); T s.next() s.next s if(T.equals ("END_OF_TEXT")) break; T.equals ("END_OF_TEXT") T.equals T "END_OF_TEXT" break; if(W.compareToIgnoreCase(T) == 0){
				count++;
			} W.compareToIgnoreCase(T) == 0 W.compareToIgnoreCase(T) W.compareToIgnoreCase W T 0 {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count public static void main(String[] args) {
	
		new Main().run();
		
	} main {
	
		new Main().run();
		
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		}

	public static void main(String[] args) {
	
		new Main().run();
		
	}
} public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		}

	public static void main(String[] args) {
	
		new Main().run();
		
	}
} Main
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		}

	public static void main(String[] args) {
	
		new Main().run();
		
	}
}