import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	}
} import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	}
} Main public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	} main {
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String w = scanner.next(); w scanner.next() scanner.next scanner int cnt = 0; cnt 0 for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		} ; {
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		} {
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		} String t = scanner.next(); t scanner.next() scanner.next scanner if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			} t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" {
				break;
			} break; if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			} w.compareToIgnoreCase(t) == 0 w.compareToIgnoreCase(t) w.compareToIgnoreCase w t 0 {
				cnt++;
			} cnt++ cnt System.out.println(cnt+"") System.out.println System.out System System.out cnt+"" cnt "" String[] args args public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	}
} public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	}
} Main
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String w = scanner.next();
		
		int cnt = 0;
		for(;;)
		{
			String t = scanner.next();
			if(t.equals("END_OF_TEXT"))
			{
				break;
			}
			else if(w.compareToIgnoreCase(t) == 0)
			{
				cnt++;
			}
		}
		
		System.out.println(cnt+"");
	}
}