import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.next(); W scan.next() scan.next scan int cnt = 0; cnt 0 for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		} ; {
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		} {
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		} String T = scan.next(); T scan.next() scan.next scan if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			} T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
				break;
			} break; {
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			} String TT = T.toLowerCase(); TT T.toLowerCase() T.toLowerCase T String WW = W.toLowerCase(); WW W.toLowerCase() W.toLowerCase W if(TT.equals(WW)){
					cnt++;
				} TT.equals(WW) TT.equals TT WW {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}