import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count=0;
    String W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  }
} 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 W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count=0;
    String W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int count=0;
    String W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count=0; count 0 String W; W W=sc.next() W sc.next() sc.next sc while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    } true {
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    } int index=0; index 0 String T=sc.next(); T sc.next() sc.next sc if(T.equals("END_OF_TEXT")) break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      } true {
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      } String w=W.toLowerCase(); w W.toLowerCase() W.toLowerCase W String t=T.toLowerCase(); t T.toLowerCase() T.toLowerCase T if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        } w.equals(t) w.equals w t {
          count+=1;
          break;
        } count+=1 count 1 break; {
          break;
        } break; System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count=0;
    String W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count=0;
    String W;
    W=sc.next();
    while(true){
      int index=0;
      String T=sc.next();
      if(T.equals("END_OF_TEXT")) break;
      while(true){
        String w=W.toLowerCase();
        String t=T.toLowerCase();
        if(w.equals(t)){
          count+=1;
          break;
        }else{
          break;
        }
      }
    }
    System.out.println(count);
      sc.close();
  }
} Main
import java.util.Scanner;

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