import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} Main public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    } main {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String w = scan.nextLine(); w scan.nextLine() scan.nextLine scan int count = 0; count 0 while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	} scan.hasNext() scan.hasNext scan {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	} String T = scan.nextLine(); T scan.nextLine() scan.nextLine scan if (T.equals("END_OF_TEXT")) {
		break;
	    } T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
		break;
	    } break; String[] Ts = T.split(" "); Ts T.split(" ") T.split T " " for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    } int i = 0; int i = 0; i 0 i < Ts.length i Ts.length Ts Ts.length i++ i++ i {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    } {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    } if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		} Ts[i].equalsIgnoreCase(w) Ts[i].equalsIgnoreCase Ts[i] Ts i 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 scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String w = scan.nextLine();
	int count = 0;
	while (scan.hasNext()) {
	    String T = scan.nextLine();
	    if (T.equals("END_OF_TEXT")) {
		break;
	    }
	    String[] Ts = T.split(" ");
	    for (int i = 0; i < Ts.length; i++) {
		if (Ts[i].equalsIgnoreCase(w)) {
		    count++;
		}
	    }
	}
	System.out.println(count);
    }
}