import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    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);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    System.out.println(count);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    System.out.println(count);
  } main {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    System.out.println(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = 0; count 0 String S S SS; SS SS = sc.next() SS sc.next() sc.next sc while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    } true {
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    } S = sc.next() S sc.next() sc.next sc if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } S.equals("END_OF_TEXT") S.equals S "END_OF_TEXT" {
        break;
      } break; {
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } if(S.equalsIgnoreCase(SS)){
          count++;
        } S.equalsIgnoreCase(SS) S.equalsIgnoreCase S SS {
          count++;
        } count++ count 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);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    System.out.println(count);
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    System.out.println(count);
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String S,SS;
    SS = sc.next();
    //System.out.println(SS);
    while(true){
      S = sc.next();
      if(S.equals("END_OF_TEXT")){
        break;
      }else{
        if(S.equalsIgnoreCase(SS)){
          count++;
        }
      } 
    }
    System.out.println(count);
  }
}
