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

class Keyword{
	String str1;
	int count = 0;

	Keyword(String str1){
		this.str1 = str1;
	}
}

class Words{
	String str2;
	static List<Words> sentence = new ArrayList<Words>();

	Words(String str2){
		this.str2 = str2;
	}
}

public class Main{
	public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	}
} import java.io.*; io.* java import java.util.*; util.* java class Keyword{
	String str1;
	int count = 0;

	Keyword(String str1){
		this.str1 = str1;
	}
} Keyword String str1; str1 int count = 0; count 0 Keyword(String str1){
		this.str1 = str1;
	} Keyword {
		this.str1 = str1;
	} this.str1 = str1 this.str1 this this.str1 str1 String str1 str1 class Words{
	String str2;
	static List<Words> sentence = new ArrayList<Words>();

	Words(String str2){
		this.str2 = str2;
	}
} Words String str2; str2 static List<Words> sentence = new ArrayList<Words>(); sentence new ArrayList<Words>() Words(String str2){
		this.str2 = str2;
	} Words {
		this.str2 = str2;
	} this.str2 = str2 this.str2 this this.str2 str2 String str2 str2 public class Main{
	public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	}
} Main public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	} main {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Keyword x = new Keyword(br.readLine()); x new Keyword(br.readLine()) while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		} true {
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		} String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("END_OF_TEXT")){
					break;
				} str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" {
					break;
				} break; String[] arr = str.split(" "); arr str.split(" ") str.split str " " for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			} int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
				Words.sentence.add(new Words(arr[i]));
			} {
				Words.sentence.add(new Words(arr[i]));
			} Words.sentence.add(new Words(arr[i])) Words.sentence.add Words.sentence Words Words.sentence new Words(arr[i]) for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		} Words y Words.sentence Words Words.sentence {
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		} {
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		} if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			} y.str2.equalsIgnoreCase(x.str1) y.str2.equalsIgnoreCase y.str2 y y.str2 x.str1 x x.str1 {
				x.count++;
			} x.count++ x.count x x.count System.out.println(x.count) System.out.println System.out System System.out x.count x x.count String[] args args public class Main{
	public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	}
} public class Main{
	public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	}
} Main
import java.io.*;
import java.util.*;

class Keyword{
	String str1;
	int count = 0;

	Keyword(String str1){
		this.str1 = str1;
	}
}

class Words{
	String str2;
	static List<Words> sentence = new ArrayList<Words>();

	Words(String str2){
		this.str2 = str2;
	}
}

public class Main{
	public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Keyword x = new Keyword(br.readLine());
	
		while(true){
			String str = br.readLine();
				if(str.equals("END_OF_TEXT")){
					break;
				}
			String[] arr = str.split(" ");

			for(int i = 0; i < arr.length; i++){
				Words.sentence.add(new Words(arr[i]));
			}
		}
		
		for(Words y : Words.sentence){
			if(y.str2.equalsIgnoreCase(x.str1)){
				x.count++;
			}
		}
		System.out.println(x.count);
	}
}