import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String w = sc.nextLine(); w sc.nextLine() sc.nextLine sc String p; p List<String> temp = new ArrayList<String>(); temp new ArrayList<String>() while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		} !(p = sc.nextLine()).equals("END_OF_TEXT") (p = sc.nextLine()).equals("END_OF_TEXT") (p = sc.nextLine()).equals (p = sc.nextLine()) p sc.nextLine() sc.nextLine sc "END_OF_TEXT" {
			for(String in : p.split(" ")){
				temp.add(in);
			}
		} for(String in : p.split(" ")){
				temp.add(in);
			} String in p.split(" ") p.split p " " {
				temp.add(in);
			} {
				temp.add(in);
			} temp.add(in) temp.add temp in int ans = 0; ans 0 for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		} String str temp {
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		} {
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		} if(str.equalsIgnoreCase(w)){
				ans++;
			} str.equalsIgnoreCase(w) str.equalsIgnoreCase str w {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		String p;
		List<String> temp = new ArrayList<String>();
		while( !(p = sc.nextLine()).equals("END_OF_TEXT")){
			for(String in : p.split(" ")){
				temp.add(in);
			}
		}
		int ans = 0;
		for(String str : temp){
			if(str.equalsIgnoreCase(w)){
				ans++;
			}
		}
		System.out.println(ans);
	}
}