import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	final static String EOF_STR = "END_OF_TEXT";
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	final static String EOF_STR = "END_OF_TEXT";
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	}
} Main final static String EOF_STR = "END_OF_TEXT"; EOF_STR "END_OF_TEXT" public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	} main {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String findStr = br.readLine().toLowerCase(); findStr br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br int findCount = 0; findCount 0 while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    } true {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    } String line = br.readLine(); line br.readLine() br.readLine br if (EOF_STR.equals(line)) break; EOF_STR.equals(line) EOF_STR.equals EOF_STR line break; line = line.toLowerCase() line line.toLowerCase() line.toLowerCase line String[] words = line.split(" "); words line.split(" ") line.split line " " for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	} int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	} {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	} if (findStr.equals(words[i])) {
	    			findCount++;
	    		} findStr.equals(words[i]) findStr.equals findStr words[i] words i {
	    			findCount++;
	    		} findCount++ findCount System.out.println(findCount) System.out.println System.out System System.out findCount String[] args args public class Main {
	final static String EOF_STR = "END_OF_TEXT";
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	}
} public class Main {
	final static String EOF_STR = "END_OF_TEXT";
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	final static String EOF_STR = "END_OF_TEXT";
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String findStr = br.readLine().toLowerCase();

	    int findCount = 0;
	    while (true) {
	    	String line = br.readLine();
	    	if (EOF_STR.equals(line)) break;

	    	line = line.toLowerCase();
	    	String[] words = line.split(" ");
	    	for (int i = 0; i < words.length; i++) {
	    		if (findStr.equals(words[i])) {
	    			findCount++;
	    		}
	    	}
	    }
        System.out.println(findCount);
	}
}