import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static Scanner sc; sc public static void main(String[] args) {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	} main {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	} String[] str= new String[1000]; str new String[1000] 1000 sc = new Scanner(System.in) sc new Scanner(System.in) int i=0; i 0 int j=0; j 0 int count=0; count 0 String search=sc.next(); search sc.next() sc.next sc for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		} ; {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		} {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		} str[i]=sc.next() str[i] str i sc.next() sc.next sc if(str[i].equals("END_OF_TEXT")) {
				break;
			} str[i].equals("END_OF_TEXT") str[i].equals str[i] str i "END_OF_TEXT" {
				break;
			} break; i++ i j++ j for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		} i=0; i=0 i 0 i<j i j i++ i++ i {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		} {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		} if(str[i].equalsIgnoreCase(search)) {
				count++;
			} str[i].equalsIgnoreCase(search) str[i].equalsIgnoreCase str[i] str i search {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		String[] str= new String[1000];
		sc = new Scanner(System.in);
		int i=0;
		int j=0;
		int count=0;
		//入力
		String search=sc.next();
		for(;;) {
			str[i]=sc.next();
			if(str[i].equals("END_OF_TEXT")) {
				break;
			}
			//System.out.println(i+str[i]);
			i++;
			j++;
		}
		//出力
		for(i=0;i<j;i++) {
			if(str[i].equalsIgnoreCase(search)) {
				count++;
			}
		}
		System.out.println(count);
	}
}

