import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String W=sc.next(); W sc.next() sc.next sc int count=0; count 0 String line=""; line "" while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		} !(line=sc.next()).equals("END_OF_TEXT") (line=sc.next()).equals("END_OF_TEXT") (line=sc.next()).equals (line=sc.next()) line sc.next() sc.next sc "END_OF_TEXT" {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		} for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			} String s line.split(" ") line.split line " " {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			} {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			} if(s.equalsIgnoreCase(W)) {
					count++;
				} s.equalsIgnoreCase(W) s.equalsIgnoreCase s W {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String W=sc.next();
		int count=0;
		String line="";
		while(!(line=sc.next()).equals("END_OF_TEXT")) {
			for(String s:line.split(" ")) {
				if(s.equalsIgnoreCase(W)) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

}
