import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count=0; count 0 String W = sc.next(); W sc.next() sc.next sc while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		} true {
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		} String T = sc.next(); T sc.next() sc.next sc if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			} T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
				break;
			} break; {
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			} T = T.toLowerCase() T T.toLowerCase() T.toLowerCase T if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				} T.equals(W)||T.equals(W+",")||T.equals(W+".") T.equals(W)||T.equals(W+",")||T.equals(W+".") T.equals(W) T.equals T W T.equals(W+",") T.equals T W+"," W "," T.equals(W+".") T.equals T W+"." W "." {
					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){
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int count=0;
		String W = sc.next();
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")){
				break;
			}else{
				T = T.toLowerCase();
				if(T.equals(W)||T.equals(W+",")||T.equals(W+".")){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}