import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str1=input.readLine();
	int i=0;
	while(true)
	    {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    }
	System.out.println(i);
    }
} import java.io.*; io.* java class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str1=input.readLine();
	int i=0;
	while(true)
	    {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    }
	System.out.println(i);
    }
} Main public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str1=input.readLine();
	int i=0;
	while(true)
	    {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    }
	System.out.println(i);
    } main {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str1=input.readLine();
	int i=0;
	while(true)
	    {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    }
	System.out.println(i);
    } BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) String str1=input.readLine(); str1 input.readLine() input.readLine input int i=0; i 0 while(true)
	    {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    } true {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    } String str=input.readLine(); str input.readLine() input.readLine input String str2[]=str.split(" "); str2 str.split(" ") str.split str " " if(str.equals("END_OF_TEXT"))break; str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" break; for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    } int j=0; int j=0; j 0 j<str2.length j str2.length str2 str2.length j++ j++ j {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    } {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    } if(str2[j].equalsIgnoreCase(str1))i++; str2[j].equalsIgnoreCase(str1) str2[j].equalsIgnoreCase str2[j] str2 j str1 i++ i System.out.println(i) System.out.println System.out System System.out i String args[] args
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str1=input.readLine();
	int i=0;
	while(true)
	    {
		String str=input.readLine();
		String str2[]=str.split(" ");
		if(str.equals("END_OF_TEXT"))break;
		for(int j=0;j<str2.length;j++)
		    {
			
			if(str2[j].equalsIgnoreCase(str1))i++;
			
		    }
		
	    }
	System.out.println(i);
    }
}