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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine().toUpperCase(); str br.readLine().toUpperCase() br.readLine().toUpperCase br.readLine() br.readLine br int count = 0; count 0 while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		} true {
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		} String req = br.readLine(); req br.readLine() br.readLine br String [] s = req.split(" "); s req.split(" ") req.split req " " if(req.endsWith("END_OF_TEXT")){
				break;
			} req.endsWith("END_OF_TEXT") req.endsWith req "END_OF_TEXT" {
				break;
			} break; for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			} int i = 0; int i = 0; i 0 i < s.length i s.length s s.length i++ i++ i {
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			} {
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			} String res = s[i].toUpperCase(); res s[i].toUpperCase() s[i].toUpperCase s[i] s i if(res.equals(str)){
					count++;
				} res.equals(str) res.equals res str {
					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)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}