import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    }
    sc.close();
    System.out.println(count);
  }
}
 import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    }
    sc.close();
    System.out.println(count);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    }
    sc.close();
    System.out.println(count);
  } main {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    }
    sc.close();
    System.out.println(count);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = 0; count 0 String w = sc.nextLine(); w sc.nextLine() sc.nextLine sc while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    } true {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    } String[] str = sc.nextLine().split(" "); str sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      } str[0].equals("END_OF_TEXT") str[0].equals str[0] str 0 "END_OF_TEXT" {
        break;
      } break; {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      } for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        } int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        } {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        } if(str[i].toLowerCase().equals(w)) {
            count++;
          } str[i].toLowerCase().equals(w) str[i].toLowerCase().equals str[i].toLowerCase() str[i].toLowerCase str[i] str i 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);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].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);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    }
    sc.close();
    System.out.println(count);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    String w = sc.nextLine();
    while(true) {
      String[] str = sc.nextLine().split(" ");
      if(str[0].equals("END_OF_TEXT")) {
        break;
      } else {
        for(int i = 0; i < str.length; i++) {
          if(str[i].toLowerCase().equals(w)) {
            count++;
          }
        }
      }
    }
    sc.close();
    System.out.println(count);
  }
}

