/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	int count = 0;
	
	BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in));

	String w = "";
    String line = "";
    while ((line = br.readLine()) != null) {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    }

	System.out.println(count);
}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	int count = 0;
	
	BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in));

	String w = "";
    String line = "";
    while ((line = br.readLine()) != null) {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    }

	System.out.println(count);
}
} Main public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	int count = 0;
	
	BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in));

	String w = "";
    String line = "";
    while ((line = br.readLine()) != null) {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    }

	System.out.println(count);
} main {
	Scanner scan = new Scanner(System.in);
	int count = 0;
	
	BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in));

	String w = "";
    String line = "";
    while ((line = br.readLine()) != null) {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    }

	System.out.println(count);
} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int count = 0; count 0 BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String w = ""; w "" String line = ""; line "" while ((line = br.readLine()) != null) {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    } if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		} w.isEmpty() w.isEmpty w {
			w = line.toLowerCase();
			continue;
		} w = line.toLowerCase() w line.toLowerCase() line.toLowerCase line continue; if ("END_OF_TEXT".equals(line)) {
			break;
		} "END_OF_TEXT".equals(line) "END_OF_TEXT".equals "END_OF_TEXT" line {
			break;
		} break; String[] words = line.split(" "); words line.split(" ") line.split line " " for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		} {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		} if (w.equals(words[i].toLowerCase())) {
				count++;
			} w.equals(words[i].toLowerCase()) w.equals w words[i].toLowerCase() words[i].toLowerCase words[i] words i {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
	Scanner scan = new Scanner(System.in);
	int count = 0;
	
	BufferedReader br =
    new BufferedReader(new InputStreamReader(System.in));

	String w = "";
    String line = "";
    while ((line = br.readLine()) != null) {
		if (w.isEmpty()) {
			w = line.toLowerCase();
			continue;
		}

		if ("END_OF_TEXT".equals(line)) {
			break;
		}

		String[] words = line.split(" ");
		for (int i = 0; i < words.length; i++) {
		if (w.equals(words[i].toLowerCase())) {
				count++;
			}
		}	    	
    }

	System.out.println(count);
}
}