import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	}

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

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	} main {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.next(); W scan.next() scan.next scan String end = "END_OF_TEXT"; end "END_OF_TEXT" int tmp = 0; tmp 0 for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		} ; {
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		} {
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		} String T = scan.next(); T scan.next() scan.next scan if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			} T.equals(end) T.equals T end {
				break;
			} break; if(T.equalsIgnoreCase(W)){
				tmp++;
			} T.equalsIgnoreCase(W) T.equalsIgnoreCase T W {
				tmp++;
			} tmp++ tmp System.out.println(tmp) System.out.println System.out System System.out tmp String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	}

} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String end = "END_OF_TEXT";
		int tmp = 0;

		for(;;){
			String T = scan.next();
			if(T.equals(end)){
				break;
			}else if(T.equalsIgnoreCase(W)){
				tmp++;
			}
		}
		System.out.println(tmp);
	}

}