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

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	}
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	}
} Main public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	} main {
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	} BufferedReader input = new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) String word = input.readLine(); word input.readLine() input.readLine input String WORD = word.toUpperCase(); WORD word.toUpperCase() word.toUpperCase word int count = 0; count 0 while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		} true {
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		} String[] str = input.readLine().split(" "); str input.readLine().split(" ") input.readLine().split input.readLine() input.readLine input " " if(str[0].equals("END_OF_TEXT"))
				break; str[0].equals("END_OF_TEXT") str[0].equals str[0] str 0 "END_OF_TEXT" break; String[] STR = new String[str.length]; STR new String[str.length] str.length str str.length for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase(); int num = 0; int num = 0; num 0 num < str.length num str.length str str.length num++ num++ num STR[num] = str[num].toUpperCase(); STR[num] = str[num].toUpperCase() STR[num] STR num str[num].toUpperCase() str[num].toUpperCase str[num] str num for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			} int num = 0; int num = 0; num 0 num < STR.length num STR.length STR STR.length num++ num++ num {
				if(STR[num].equals(WORD))
				{
					count++;
				}
			} {
				if(STR[num].equals(WORD))
				{
					count++;
				}
			} if(STR[num].equals(WORD))
				{
					count++;
				} STR[num].equals(WORD) STR[num].equals STR[num] STR num WORD {
					count++;
				} count++ count 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 IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	}
} public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		String word = input.readLine();

		String WORD = word.toUpperCase();

		int count = 0;

		while(true)
		{
			String[] str = input.readLine().split(" ");

			if(str[0].equals("END_OF_TEXT"))
				break;

			String[] STR = new String[str.length];

			for(int num = 0; num < str.length; num++)
				STR[num] = str[num].toUpperCase();

			//単語の数を数える
			for(int num = 0; num < STR.length; num++)
			{
				if(STR[num].equals(WORD))
				{
					count++;
				}
			}
		}

		System.out.println(count);
	}
}

