import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} Main public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    } exec {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String W = br.readLine(); W br.readLine() br.readLine br int count=0; count 0 while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	} true {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	} String line = br.readLine(); line br.readLine() br.readLine br if ("END_OF_TEXT".equals(line))
        		break; "END_OF_TEXT".equals(line) "END_OF_TEXT".equals "END_OF_TEXT" line break; String[] words = line.split(" "); words line.split(" ") line.split line " " for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++; String word words if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++; if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++; W.toLowerCase().equals(word.toLowerCase()) W.toLowerCase().equals W.toLowerCase() W.toLowerCase W word.toLowerCase() word.toLowerCase word count++ count out.println(count) out.println out count out.flush() out.flush out public static void main(String[] args) throws IOException {
    	new Main().exec();
    } main {
    	new Main().exec();
    } new Main().exec() new Main().exec new Main() String[] args args public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String W = br.readLine();
    	int count=0;
    	while(true) {
        	String line = br.readLine();
        	if ("END_OF_TEXT".equals(line))
        		break;
        	String[] words = line.split(" ");
        	for(String word: words)
        		if(W.toLowerCase().equals(word.toLowerCase())) 
        			count++;
    	}
    	out.println(count);
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}