

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

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

   int serchcount = 0;
   while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   }


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

   int serchcount = 0;
   while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   }


   System.out.println(serchcount);
  }
} Main public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   String serch =  br.readLine().toUpperCase();

   int serchcount = 0;
   while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   }


   System.out.println(serchcount);
  } main {
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   String serch =  br.readLine().toUpperCase();

   int serchcount = 0;
   while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   }


   System.out.println(serchcount);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String serch =  br.readLine().toUpperCase(); serch br.readLine().toUpperCase() br.readLine().toUpperCase br.readLine() br.readLine br int serchcount = 0; serchcount 0 while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   } true {

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   } String original =  br.readLine(); original br.readLine() br.readLine br if( original.equals("END_OF_TEXT") ) break; original.equals("END_OF_TEXT") original.equals original "END_OF_TEXT" break; String[] cut =  original.toUpperCase().split(" "); cut original.toUpperCase().split(" ") original.toUpperCase().split original.toUpperCase() original.toUpperCase original " " for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 } int i = 0 ; int i = 0 ; i 0 i < cut.length i cut.length cut cut.length i++ i++ i {

		 if( cut[i].equals(serch) )  serchcount++;

	 } {

		 if( cut[i].equals(serch) )  serchcount++;

	 } if( cut[i].equals(serch) )  serchcount++; cut[i].equals(serch) cut[i].equals cut[i] cut i serch serchcount++ serchcount System.out.println(serchcount) System.out.println System.out System System.out serchcount String args[] args


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

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

   int serchcount = 0;
   while(true){

	  String original =  br.readLine();
	  if( original.equals("END_OF_TEXT") ) break;


     String[] cut =  original.toUpperCase().split(" ");


	 for(int i = 0 ;i < cut.length;i++){

		 if( cut[i].equals(serch) )  serchcount++;

	 }

   }


   System.out.println(serchcount);
  }
}