

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

public class Main{

	public static void main(String[] args) throws IOException
	{
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	}
} 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
	{
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	}
} Main public static void main(String[] args) throws IOException
	{
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	} main {
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	} int nCount=0; nCount 0 BufferedReader br = new BufferedReader(new InputStreamReader(System.in) ); br new BufferedReader(new InputStreamReader(System.in) ) String strWord = br.readLine(); strWord br.readLine() br.readLine br while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		} true {
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		} String[] strText = br.readLine().split(" "); strText br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " if(strText[0].equals("END_OF_TEXT") ) break; strText[0].equals("END_OF_TEXT") strText[0].equals strText[0] strText 0 "END_OF_TEXT" break; for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			} String str strText {
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			} {
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			} if(str.equalsIgnoreCase(strWord) ) nCount++; str.equalsIgnoreCase(strWord) str.equalsIgnoreCase str strWord nCount++ nCount System.out.println(nCount) System.out.println System.out System System.out nCount String[] args args public class Main{

	public static void main(String[] args) throws IOException
	{
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	}
} public class Main{

	public static void main(String[] args) throws IOException
	{
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	}
} Main


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

public class Main{

	public static void main(String[] args) throws IOException
	{
		int nCount=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String strWord = br.readLine();

		while(true)
		{
			String[] strText = br.readLine().split(" ");
			if(strText[0].equals("END_OF_TEXT") ) break;

			for(String str : strText)
			{
				if(str.equalsIgnoreCase(strWord) ) nCount++;
			}
		}

		System.out.println(nCount);

	}
}