import java.util.*;
import java.io.*;
import static java.lang.System.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  }
} import java.util.*; util.* java import java.io.*; io.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  } main {
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String word = sc.nextLine(); word sc.nextLine() sc.nextLine sc int count=0; count 0 while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    } true {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    } String s = sc.next(); s sc.next() sc.next sc if(s.equals("END_OF_TEXT")) break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; if(word.equals(s.toLowerCase()))
      {
        count++;
      } word.equals(s.toLowerCase()) word.equals word s.toLowerCase() s.toLowerCase s {
        count++;
      } count++ count out.println(count) out.println out count String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  }
} Main
import java.util.*;
import java.io.*;
import static java.lang.System.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String word = sc.nextLine();
    int count=0;
    while(true)
    {
      String s = sc.next();
      if(s.equals("END_OF_TEXT")) break;
      if(word.equals(s.toLowerCase()))
      {
        count++;
      }
    }
    out.println(count);
  }
}
