//????????????????????????????¨?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String serchWord = br.readLine().toLowerCase();
		
		int cnt = 0;
		boolean flg = true;
		String endWord ="END_OF_TEXT";
		
		while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		}
		System.out.println(cnt);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String serchWord = br.readLine().toLowerCase();
		
		int cnt = 0;
		boolean flg = true;
		String endWord ="END_OF_TEXT";
		
		while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String serchWord = br.readLine().toLowerCase();
		
		int cnt = 0;
		boolean flg = true;
		String endWord ="END_OF_TEXT";
		
		while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		}
		System.out.println(cnt);
	} main {
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String serchWord = br.readLine().toLowerCase();
		
		int cnt = 0;
		boolean flg = true;
		String endWord ="END_OF_TEXT";
		
		while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		}
		System.out.println(cnt);
	} BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String serchWord = br.readLine().toLowerCase(); serchWord br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br int cnt = 0; cnt 0 boolean flg = true; flg true String endWord ="END_OF_TEXT"; endWord "END_OF_TEXT" while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		} flg {
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		} String[] sentence = br.readLine().split(" "); sentence br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			} int i=0; int i=0; i 0 i<sentence.length i sentence.length sentence sentence.length i++ i++ i {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			} {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			} if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				} sentence[i].toLowerCase().equals(serchWord) sentence[i].toLowerCase().equals sentence[i].toLowerCase() sentence[i].toLowerCase sentence[i] sentence i serchWord {
					cnt = cnt + 1;
				} cnt = cnt + 1 cnt cnt + 1 cnt 1 if(sentence[i].equals(endWord)) {
					flg = false;
				} sentence[i].equals(endWord) sentence[i].equals sentence[i] sentence i endWord {
					flg = false;
				} flg = false flg false System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args
//????????????????????????????¨?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String serchWord = br.readLine().toLowerCase();
		
		int cnt = 0;
		boolean flg = true;
		String endWord ="END_OF_TEXT";
		
		while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		}
		System.out.println(cnt);
	}
}