import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	} main {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String W = scan.next(); W scan.next() scan.next scan String w = W.toLowerCase(); w W.toLowerCase() W.toLowerCase W int i = 0; i 0 while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		} true {
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		} String Ti = scan.next(); Ti scan.next() scan.next scan if (Ti.equals("END_OF_TEXT")) break; Ti.equals("END_OF_TEXT") Ti.equals Ti "END_OF_TEXT" break; String ti = Ti.toLowerCase(); ti Ti.toLowerCase() Ti.toLowerCase Ti if (ti.equals(w)) i++; ti.equals(w) ti.equals ti w i++ i System.out.println(i) System.out.println System.out System System.out i String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		String w = W.toLowerCase();
		
		int i = 0;
		while(true){
			String Ti = scan.next();
			if (Ti.equals("END_OF_TEXT")) break;
			String ti = Ti.toLowerCase();
			if (ti.equals(w)) i++;
		}
		System.out.println(i);
		

	}

}