import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	}
} Main public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	} try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		} {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int cnt = 0; cnt 0 String W = sc.nextLine(); W sc.nextLine() sc.nextLine sc while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			} true {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			} String T = sc.nextLine(); T sc.nextLine() sc.nextLine sc if(T.equals("END_OF_TEXT") )	break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; String[] t = T.toLowerCase().split(" "); t T.toLowerCase().split(" ") T.toLowerCase().split T.toLowerCase() T.toLowerCase T " " for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				} String i t {
					if(i.equals(W)) {
						cnt++;
					}
				} {
					if(i.equals(W)) {
						cnt++;
					}
				} if(i.equals(W)) {
						cnt++;
					} i.equals(W) i.equals 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) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	}
} public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	}
} Main
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			String W = sc.nextLine();
			while(true) {
				String T = sc.nextLine();
				
				if(T.equals("END_OF_TEXT") )	break;
				
				String[] t = T.toLowerCase().split(" ");
				for(String i:t) {
					if(i.equals(W)) {
						cnt++;
					}
				}
				
			}
			System.out.println(cnt);
			
			
			
		}
	}
}
