import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	}
	
	public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	}
	
	public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine().toUpperCase(); w sc.nextLine().toUpperCase() sc.nextLine().toUpperCase sc.nextLine() sc.nextLine sc String t = sc.nextLine(); t sc.nextLine() sc.nextLine sc int w_count = 0; w_count 0 while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		} !t.equals("END_OF_TEXT") t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" {
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		} String t_array[] = t.split(" "); t_array t.split(" ") t.split t " " w_count += seek_word_in_w(w, t_array) w_count seek_word_in_w(w, t_array) seek_word_in_w w t_array t = sc.nextLine() t sc.nextLine() sc.nextLine sc System.out.println(w_count) System.out.println System.out System System.out w_count String[] args args public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	} seek_word_in_w {
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	} int w_count = 0; w_count 0 for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    } String t_word t_array {
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    } {
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    } if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } t_word.toUpperCase().equals(w) t_word.toUpperCase().equals t_word.toUpperCase() t_word.toUpperCase t_word w {
	            w_count++;
	        } w_count++ w_count return w_count; w_count String w w String []t_array t_array public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	}
	
	public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	}
} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	}
	
	public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toUpperCase();
		String t = sc.nextLine();
		int w_count = 0;

		while(!t.equals("END_OF_TEXT")){
		    String t_array[] = t.split(" ");
		    w_count += seek_word_in_w(w, t_array);
		    t = sc.nextLine();
		}
		
		System.out.println(w_count);
	}
	
	public static int seek_word_in_w(String w, String []t_array){
	    int w_count = 0;
	    
	    for (String t_word: t_array){
	        if (t_word.toUpperCase().equals(w)){
	            w_count++;
	        } 
	    }
	    
	    return w_count;
	}
}
