/* ITP1_9_A */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    }
  }
} import java.io.*; io.* java class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    }
  }
} Main public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    }
  } main {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    }
  } try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    } catch(Exception e){
      System.out.println(e);
    } Exception e {
      System.out.println(e);
    } System.out.println(e) System.out.println System.out System System.out e {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    } 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 String t; t int count = 0; count 0 while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      } (t = br.readLine()).equals("END_OF_TEXT") == false (t = br.readLine()).equals("END_OF_TEXT") (t = br.readLine()).equals (t = br.readLine()) t br.readLine() br.readLine br "END_OF_TEXT" false {

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      } String[] word = t.split(" "); word t.split(" ") t.split t " " for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        } String str word {
          if(str.equalsIgnoreCase(w)) count++;
        } {
          if(str.equalsIgnoreCase(w)) count++;
        } if(str.equalsIgnoreCase(w)) count++; str.equalsIgnoreCase(w) str.equalsIgnoreCase str w count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
/* ITP1_9_A */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    }
  }
}