import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	}
	public static void main(String args[]){
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	}
	public static void main(String args[]){
		new Main().run();
	}
} Main void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	} run {
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) String W = s.next().toLowerCase(); W s.next().toLowerCase() s.next().toLowerCase s.next() s.next s String T=""; T "" String txt = ""; txt "" int cnt=0; cnt 0 while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		} true {
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		} if(W.equals(txt))cnt++; W.equals(txt) W.equals W txt cnt++ cnt txt = s.next() txt s.next() s.next s if("END_OF_TEXT".equals(txt)){
				break;
			} "END_OF_TEXT".equals(txt) "END_OF_TEXT".equals "END_OF_TEXT" txt {
				break;
			} break; txt = txt.toLowerCase() txt txt.toLowerCase() txt.toLowerCase txt System.out.println(cnt) System.out.println System.out System System.out cnt public static void main(String args[]){
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String args[] args public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	}
	public static void main(String args[]){
		new Main().run();
	}
} public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	}
	public static void main(String args[]){
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next().toLowerCase();
		String T="";
		String txt = "";
		int cnt=0;
		while(true){
			if(W.equals(txt))cnt++;
			txt = s.next();
			if("END_OF_TEXT".equals(txt)){
				break;
			}
			txt = txt.toLowerCase();
		}
		System.out.println(cnt);
	}
	public static void main(String args[]){
		new Main().run();
	}
}