import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String W=" "+in.nextLine()+" ";
        String T="";
        String n=in.nextLine();
        while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        }
        int c=0;
        int i=-1;
        int l=W.length();
        while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        }
        System.out.println(c);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String W=" "+in.nextLine()+" ";
        String T="";
        String n=in.nextLine();
        while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        }
        int c=0;
        int i=-1;
        int l=W.length();
        while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        }
        System.out.println(c);
	}
} Main public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String W=" "+in.nextLine()+" ";
        String T="";
        String n=in.nextLine();
        while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        }
        int c=0;
        int i=-1;
        int l=W.length();
        while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        }
        System.out.println(c);
	} main {
		Scanner in = new Scanner(System.in);
		String W=" "+in.nextLine()+" ";
        String T="";
        String n=in.nextLine();
        while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        }
        int c=0;
        int i=-1;
        int l=W.length();
        while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        }
        System.out.println(c);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String W=" "+in.nextLine()+" "; W " "+in.nextLine()+" " " "+in.nextLine()+" " " " in.nextLine() in.nextLine in " " String T=""; T "" String n=in.nextLine(); n in.nextLine() in.nextLine in while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        } !n.equals("END_OF_TEXT") n.equals("END_OF_TEXT") n.equals n "END_OF_TEXT" {
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        } T+=" "+n.toLowerCase().replace(" ", "  ")+" " T " "+n.toLowerCase().replace(" ", "  ")+" " " "+n.toLowerCase().replace(" ", "  ")+" " " " n.toLowerCase().replace(" ", "  ") n.toLowerCase().replace n.toLowerCase() n.toLowerCase n " " "  " " " n=in.nextLine() n in.nextLine() in.nextLine in int c=0; c 0 int i=-1; i -1 1 int l=W.length(); l W.length() W.length W while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        } true {
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        } i=T.indexOf(W, i+1) i T.indexOf(W, i+1) T.indexOf T W i+1 i 1 if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            } i==-1 i -1 1 {
            	break;
            } break; {
            	c++;
            	i+=l-1;
            } c++ c i+=l-1 i l-1 l 1 System.out.println(c) System.out.println System.out System System.out c String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String W=" "+in.nextLine()+" ";
        String T="";
        String n=in.nextLine();
        while(!n.equals("END_OF_TEXT")){
        	T+=" "+n.toLowerCase().replace(" ", "  ")+" ";
        	n=in.nextLine();
        }
        int c=0;
        int i=-1;
        int l=W.length();
        while(true){
            i=T.indexOf(W, i+1);
            if(i==-1){
            	break;
            }else{
            	c++;
            	i+=l-1;
            }
        }
        System.out.println(c);
	}
}