import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	}

} Main public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String w=br.readLine(); w br.readLine() br.readLine br w=w.toLowerCase() w w.toLowerCase() w.toLowerCase w int cnt=0; cnt 0 int sw=0; sw 0 int ln=0; ln 0 while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		} sw==0 sw 0 {
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		} ln++ ln String str=br.readLine(); str br.readLine() br.readLine br if(str.equals("END_OF_TEXT")){ sw=1;break;} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" { sw=1;break;} sw=1 sw 1 break; str=str.toLowerCase() str str.toLowerCase() str.toLowerCase str String[] t=str.split(" "); t str.split(" ") str.split str " " for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			} int i=0; int i=0; i 0 i<t.length i t.length t t.length i++ i++ i {
				if(t[i].equals(w))	{cnt++;}
			} {
				if(t[i].equals(w))	{cnt++;}
			} if(t[i].equals(w))	{cnt++;} t[i].equals(w) t[i].equals t[i] t i w {cnt++;} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	}

} public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String w=br.readLine();
		w=w.toLowerCase();
		int cnt=0;
		int sw=0;
		int ln=0;
		while(sw==0){
			ln++;
			String str=br.readLine();
			if(str.equals("END_OF_TEXT")){ sw=1;break;}
			str=str.toLowerCase();
			String[] t=str.split(" ");
			for(int i=0;i<t.length;i++){
				if(t[i].equals(w))	{cnt++;}
			}
		}
		System.out.println(cnt);
		
	}

}