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

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	}
} 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 br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String w = br.readLine(); w br.readLine() br.readLine br StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		} sb.indexOf("END_OF_TEXT") == -1 sb.indexOf("END_OF_TEXT") sb.indexOf sb "END_OF_TEXT" -1 1 {
			sb.append(" " + br.readLine());
		} sb.append(" " + br.readLine()) sb.append sb " " + br.readLine() " " br.readLine() br.readLine br StringBuilder sb2 = new StringBuilder(); sb2 new StringBuilder() sb2.append(sb.toString().toLowerCase()) sb2.append sb2 sb.toString().toLowerCase() sb.toString().toLowerCase sb.toString() sb.toString sb int chk = 0 chk 0 sum = 0; sum 0 while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		} true {
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		} chk = sb2.indexOf(" " + w + " ", chk) chk sb2.indexOf(" " + w + " ", chk) sb2.indexOf sb2 " " + w + " " " " + w + " " " " w " " chk if(chk==-1)	break; chk==-1 chk -1 1 break; sum++ sum chk++ chk System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	}
} public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	}
} 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 br = new BufferedReader(new InputStreamReader(System.in));
		String w = br.readLine();
		StringBuilder sb = new StringBuilder();
		while(sb.indexOf("END_OF_TEXT") == -1)
		{
			sb.append(" " + br.readLine());
		}
		StringBuilder sb2 = new StringBuilder();
		sb2.append(sb.toString().toLowerCase());
		int chk = 0, sum = 0;
		while(true)
		{
			chk = sb2.indexOf(" " + w + " ", chk);
			if(chk==-1)	break;
			sum++;
			chk++;
		}
		System.out.println(sum);
	}
}