import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  }

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  }

} Main public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  } main {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  } Scanner stdin = new Scanner(System.in); stdin new Scanner(System.in) String W = stdin.next().toUpperCase(); W stdin.next().toUpperCase() stdin.next().toUpperCase stdin.next() stdin.next stdin int n = 0; n 0 while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    } true {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    } String T = stdin.next(); T stdin.next() stdin.next stdin if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      } T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" {
        break;
      } break; if (T.toUpperCase().equals(W)) {
        n++;
      } T.toUpperCase().equals(W) T.toUpperCase().equals T.toUpperCase() T.toUpperCase T W {
        n++;
      } n++ n System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  }

} public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  }

} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  }

}