public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	}

} public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	} main {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	} java.util.Scanner scan = new java.util.Scanner(System.in); scan new java.util.Scanner(System.in) String W = scan.next().toLowerCase(); W scan.next().toLowerCase() scan.next().toLowerCase scan.next() scan.next scan int count = 0; count 0 while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		} true {
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		} String str = scan.next(); str scan.next() scan.next scan if("END_OF_TEXT".equals(str)){
				break;
			} "END_OF_TEXT".equals(str) "END_OF_TEXT".equals "END_OF_TEXT" str {
				break;
			} break; if(W.equalsIgnoreCase(str)){
				count++;
			} W.equalsIgnoreCase(str) W.equalsIgnoreCase W str {
				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){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	}

} public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	}

} Main
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		String W = scan.next().toLowerCase();
		int count = 0;
		while(true){
			String str = scan.next();

			if("END_OF_TEXT".equals(str)){
				break;
			}
			if(W.equalsIgnoreCase(str)){
				count++;
			}
		}
		System.out.println(count);
	}

}