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

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	}

} Main public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) String w = br.readLine(); w br.readLine() br.readLine br int count = 0; count 0 int owari = 0; owari 0 while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	} true {
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	} String[] si = br.readLine().split(" "); si br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	} int i = 0; int i = 0; i 0 i < si.length i si.length si si.length i++ i++ i {
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	} {
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	} if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			} si[i].equals("END_OF_TEXT") si[i].equals si[i] si i "END_OF_TEXT" {
        				owari++;
        				break;
        			} owari++ owari break; String so = si[i]; so si[i] si i if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		} w.equalsIgnoreCase(so) w.equalsIgnoreCase w so {
        						count++;
                    		} count++ count if (owari == 1)
        		break; owari == 1 owari 1 break; 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 Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	}

} public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
    	String w = br.readLine();
    	int count = 0;
    	int owari = 0;
    	while (true)
    	{
    		String[] si = br.readLine().split(" ");
        	for (int i = 0; i < si.length; i++)
        	{
        		if (si[i].equals("END_OF_TEXT"))
        			{
        				owari++;
        				break;
        			}
        		String so = si[i];
        				if (w.equalsIgnoreCase(so))
                    		{
        						count++;
                    		}
        	}
        	if (owari == 1)
        		break;
    	}
    	System.out.println(count);
	}

}