import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toLowerCase();
		int count=0;
		
		while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		}
		System.out.println(count);
	}
}	 import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toLowerCase();
		int count=0;
		
		while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toLowerCase();
		int count=0;
		
		while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toLowerCase();
		int count=0;
		
		while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine().toLowerCase(); w sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int count=0; count 0 while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		} true {
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		} String[] line = sc.nextLine().split(" "); line sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " if(line[0].equals("END_OF_TEXT")){
				break;
			} line[0].equals("END_OF_TEXT") line[0].equals line[0] line 0 "END_OF_TEXT" {
				break;
			} break; for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			} int i=0; int i=0; i 0 i<line.length i line.length line line.length i++ i++ i {
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			} {
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			} if(w.equals(line[i].toLowerCase())){
					count+=1;
				} w.equals(line[i].toLowerCase()) w.equals w line[i].toLowerCase() line[i].toLowerCase line[i] line i {
					count+=1;
				} count+=1 count 1 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toLowerCase();
		int count=0;
		
		while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		}
		System.out.println(count);
	}
}	