import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

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

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

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

	public static void main(String[] args){
		int count = 0;
		String W = scan.next();
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}
			String w = W.toLowerCase();
			String t = T.toLowerCase();
			if(t.equals(w)){
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int count = 0;
		String W = scan.next();
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}
			String w = W.toLowerCase();
			String t = T.toLowerCase();
			if(t.equals(w)){
				count++;
			}
		}
		System.out.println(count);
	}
}