import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		String s1;
		ArrayList<String> al=new ArrayList<String>();
		int i=0;
		s1=scan.next().toLowerCase();
		while(scan.hasNext()){
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		}
		int s=al.size();
		int c=0;
		for(int m=0;m<s;m++)
		{
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		}
		System.out.println(c);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		String s1;
		ArrayList<String> al=new ArrayList<String>();
		int i=0;
		s1=scan.next().toLowerCase();
		while(scan.hasNext()){
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		}
		int s=al.size();
		int c=0;
		for(int m=0;m<s;m++)
		{
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		}
		System.out.println(c);
	}
} Main public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		String s1;
		ArrayList<String> al=new ArrayList<String>();
		int i=0;
		s1=scan.next().toLowerCase();
		while(scan.hasNext()){
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		}
		int s=al.size();
		int c=0;
		for(int m=0;m<s;m++)
		{
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		}
		System.out.println(c);
	} main {
		Scanner scan=new Scanner(System.in);
		String s1;
		ArrayList<String> al=new ArrayList<String>();
		int i=0;
		s1=scan.next().toLowerCase();
		while(scan.hasNext()){
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		}
		int s=al.size();
		int c=0;
		for(int m=0;m<s;m++)
		{
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		}
		System.out.println(c);
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String s1; s1 ArrayList<String> al=new ArrayList<String>(); al new ArrayList<String>() int i=0; i 0 s1=scan.next().toLowerCase() s1 scan.next().toLowerCase() scan.next().toLowerCase scan.next() scan.next scan while(scan.hasNext()){
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		} scan.hasNext() scan.hasNext scan {
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		} al.add(scan.next()) al.add al scan.next() scan.next scan if(al.get(i).equals("END_OF_TEXT"))
				break; al.get(i).equals("END_OF_TEXT") al.get(i).equals al.get(i) al.get al i "END_OF_TEXT" break; i++ i int s=al.size(); s al.size() al.size al int c=0; c 0 for(int m=0;m<s;m++)
		{
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		} int m=0; int m=0; m 0 m<s m s m++ m++ m {
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		} {
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		} if(al.get(m).toLowerCase().equals(s1))
				c++; al.get(m).toLowerCase().equals(s1) al.get(m).toLowerCase().equals al.get(m).toLowerCase() al.get(m).toLowerCase al.get(m) al.get al m s1 c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		String s1;
		ArrayList<String> al=new ArrayList<String>();
		int i=0;
		s1=scan.next().toLowerCase();
		while(scan.hasNext()){
			al.add(scan.next());
			if(al.get(i).equals("END_OF_TEXT"))
				break;
			i++;
			
		}
		int s=al.size();
		int c=0;
		for(int m=0;m<s;m++)
		{
			if(al.get(m).toLowerCase().equals(s1))
				c++;
		}
		System.out.println(c);
	}
}