import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=" "+br.readLine().toLowerCase()+" ";
        String T=" ",n;
        while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        }
    	T=T.toLowerCase();
        System.out.println(count(T,W));
	}
	
	private static int count(String str, String reg){
		int c=0,r=0;
		while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		}
		return r;
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=" "+br.readLine().toLowerCase()+" ";
        String T=" ",n;
        while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        }
    	T=T.toLowerCase();
        System.out.println(count(T,W));
	}
	
	private static int count(String str, String reg){
		int c=0,r=0;
		while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		}
		return r;
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=" "+br.readLine().toLowerCase()+" ";
        String T=" ",n;
        while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        }
    	T=T.toLowerCase();
        System.out.println(count(T,W));
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=" "+br.readLine().toLowerCase()+" ";
        String T=" ",n;
        while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        }
    	T=T.toLowerCase();
        System.out.println(count(T,W));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W=" "+br.readLine().toLowerCase()+" "; W " "+br.readLine().toLowerCase()+" " " "+br.readLine().toLowerCase()+" " " " br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br " " String T=" " T " " n; n while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        } true {
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        } n=br.readLine() n br.readLine() br.readLine br if(n.equals("END_OF_TEXT")) break; n.equals("END_OF_TEXT") n.equals n "END_OF_TEXT" break; T+=n+" " T n+" " n " " T=T.toLowerCase() T T.toLowerCase() T.toLowerCase T System.out.println(count(T,W)) System.out.println System.out System System.out count(T,W) count T W String[] args args private static int count(String str, String reg){
		int c=0,r=0;
		while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		}
		return r;
	} count {
		int c=0,r=0;
		while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		}
		return r;
	} int c=0 c 0 r=0; r 0 while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		} true {
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		} c=str.indexOf(reg,c) c str.indexOf(reg,c) str.indexOf str reg c if(c==-1) break; c==-1 c -1 1 break; r++ r c++ c return r; r String str str String reg reg
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=" "+br.readLine().toLowerCase()+" ";
        String T=" ",n;
        while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        }
    	T=T.toLowerCase();
        System.out.println(count(T,W));
	}
	
	private static int count(String str, String reg){
		int c=0,r=0;
		while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		}
		return r;
	}
}