import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  } main {
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String W = sc.next().toLowerCase(); W sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc String T; T int count=0; count 0 while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    } !(T = sc.next()).equals("END_OF_TEXT") (T = sc.next()).equals("END_OF_TEXT") (T = sc.next()).equals (T = sc.next()) T sc.next() sc.next sc "END_OF_TEXT" {
      if(T.toLowerCase().equals(W)){
        count++;
      }
    } if(T.toLowerCase().equals(W)){
        count++;
      } T.toLowerCase().equals(W) T.toLowerCase().equals T.toLowerCase() T.toLowerCase T W {
        count++;
      } count++ count sc.close() sc.close sc System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String W = sc.next().toLowerCase();
    String T;
    int count=0;

    while(!(T = sc.next()).equals("END_OF_TEXT")){
      if(T.toLowerCase().equals(W)){
        count++;
      }
    }
    sc.close();
    System.out.println(count);
  }
}
