import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main
   
   
}//class import java.util.*; util.* java import java.text.*; text.* java public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main
   
   
}//class Main public static final String EOF = "END_OF_TEXT"; EOF "END_OF_TEXT" public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main main {
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String keyWord = sc.nextLine().toLowerCase(); keyWord sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int count = 0; count 0 String[] strArr; strArr boolean exit = false; exit false while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      } !exit exit {
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      } strArr = sc.nextLine().split(" ") strArr sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         } int i = 0; int i = 0; i 0 i < strArr.length i strArr.length strArr strArr.length i ++ i ++ i {
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         } {
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         } if(strArr[i].equals(EOF)){
               exit = true;
               break;
            } strArr[i].equals(EOF) strArr[i].equals strArr[i] strArr i EOF {
               exit = true;
               break;
            } exit = true exit true break; if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            } strArr[i].toLowerCase().equals(keyWord) strArr[i].toLowerCase().equals strArr[i].toLowerCase() strArr[i].toLowerCase strArr[i] strArr i keyWord {
               count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main
   
   
}//class public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main
   
   
}//class Main
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main
   
   
}//class
