import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner as = new Scanner(System.in);
		
		String T = "";
		String TD;
		String W;
		String str = "";
		int j = 0;
		int i = 0;
		int k = 0;
		int count = 0;
		int same = 0;
		int flag = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);
	    
	    

	}

} import java.util.Scanner; Scanner java.util class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner as = new Scanner(System.in);
		
		String T = "";
		String TD;
		String W;
		String str = "";
		int j = 0;
		int i = 0;
		int k = 0;
		int count = 0;
		int same = 0;
		int flag = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);
	    
	    

	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner as = new Scanner(System.in);
		
		String T = "";
		String TD;
		String W;
		String str = "";
		int j = 0;
		int i = 0;
		int k = 0;
		int count = 0;
		int same = 0;
		int flag = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);
	    
	    

	} main {
		// TODO Auto-generated method stub
Scanner as = new Scanner(System.in);
		
		String T = "";
		String TD;
		String W;
		String str = "";
		int j = 0;
		int i = 0;
		int k = 0;
		int count = 0;
		int same = 0;
		int flag = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);
	    
	    

	} Scanner as = new Scanner(System.in); as new Scanner(System.in) String T = ""; T "" String TD; TD String W; W String str = ""; str "" int j = 0; j 0 int i = 0; i 0 int k = 0; k 0 int count = 0; count 0 int same = 0; same 0 int flag = 0; flag 0 W = as.nextLine() W as.nextLine() as.nextLine as W = W.toLowerCase() W W.toLowerCase() W.toLowerCase W while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        } as.hasNext() as.hasNext as {                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        } T = as.next() T as.next() as.next as T = T.toLowerCase() T T.toLowerCase() T.toLowerCase T if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	} T == "END_OF_TEXT" T "END_OF_TEXT" {
		    
	    		break;
	    		
	    	} break; if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	} T.indexOf(W) == 0 && T.lastIndexOf(W) == 0 T.indexOf(W) == 0 T.indexOf(W) T.indexOf T W 0 T.lastIndexOf(W) == 0 T.lastIndexOf(W) T.lastIndexOf T W 0 {
	    		
	    		count++;
	    		
	    	} count++ count str = String.valueOf(count) str String.valueOf(count) String.valueOf String count System.out.println(str) System.out.println System.out System System.out str String[] args args
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner as = new Scanner(System.in);
		
		String T = "";
		String TD;
		String W;
		String str = "";
		int j = 0;
		int i = 0;
		int k = 0;
		int count = 0;
		int same = 0;
		int flag = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);
	    
	    

	}

}