import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	} main {
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	} Scanner std = new Scanner(System.in); std new Scanner(System.in) int ans = 0; ans 0 String search = std.next().toLowerCase(); search std.next().toLowerCase() std.next().toLowerCase std.next() std.next std while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		} std.hasNext() std.hasNext std {
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		} String word = std.next().toLowerCase(); word std.next().toLowerCase() std.next().toLowerCase std.next() std.next std if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			} word.equals("END_OF_TEXT") word.equals word "END_OF_TEXT" {
				break;
			} break; if(word.equals(search)){
				ans++;
			} word.equals(search) word.equals word search {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int ans = 0;
		String search = std.next().toLowerCase();
		while(std.hasNext()){
			String word = std.next().toLowerCase();
			if(word.equals("END_OF_TEXT")){
				break;
			}else if(word.equals(search)){
				ans++;
			}
		}
		System.out.println(ans);
	}
}