import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	} BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); sc new BufferedReader(new InputStreamReader(System.in)) String st = sc.readLine(); st sc.readLine() sc.readLine sc int count = 0; count 0 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) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		String st = sc.readLine();
		int count = 0;
		flag:
		while(true){
			String[] s = sc.readLine().split(" ");
			for(String i:s){
				if(i.equals("END_OF_TEXT")){
					break flag;
				}else if(i.equalsIgnoreCase(st)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}