import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	}

}
 import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	}

} Main public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	} main {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) PrintWriter out=new PrintWriter(System.out); out new PrintWriter(System.out) String word=in.nextLine() word in.nextLine() in.nextLine in str = in.nextLine()+" "; str in.nextLine()+" " in.nextLine() in.nextLine in " " while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		} true {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		} String tstr=in.nextLine(); tstr in.nextLine() in.nextLine in if(tstr.equals("END_OF_TEXT"))break; tstr.equals("END_OF_TEXT") tstr.equals tstr "END_OF_TEXT" break; str+=tstr+" " str tstr+" " tstr " " word=word.toUpperCase() word word.toUpperCase() word.toUpperCase word str=str.toUpperCase() str str.toUpperCase() str.toUpperCase str String words[]=str.split(" "); words str.split(" ") str.split str " " int cnt=0; cnt 0 for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		} int i=0; int i=0; i 0 i<words.length i words.length words words.length i++ i++ i {
			if(words[i].equals(word))cnt++;
		} {
			if(words[i].equals(word))cnt++;
		} if(words[i].equals(word))cnt++; words[i].equals(word) words[i].equals words[i] words i word cnt++ cnt out.println(cnt) out.println out cnt out.flush() out.flush out String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	}

} Main
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		String word=in.nextLine(),str = in.nextLine()+" ";
		while(true) {
			String tstr=in.nextLine();
			if(tstr.equals("END_OF_TEXT"))break;
			str+=tstr+" ";
		}
		word=word.toUpperCase(); str=str.toUpperCase();
		
		String words[]=str.split(" ");
		//for(int i=0;i<words.length;i++)out.println(words[i]);
		int cnt=0;
		
		for(int i=0;i<words.length;i++) {
			if(words[i].equals(word))cnt++;
		}
		out.println(cnt);
		out.flush();
	}

}

