public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  } run {
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  } java.util.Scanner sc = new java.util.Scanner(in); sc new java.util.Scanner(in) String w w t; t int count count i i wm wm tm; tm char[] wch wch tch; tch count = 0 count 0 w = sc.next() w sc.next() sc.next sc wm = w.length() wm w.length() w.length w wch = new char[wm] wch new char[wm] wm for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    } i = 0; i = 0 i 0 i < wm i wm i++ i++ i {
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    } {
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    } wch[i] = w.charAt(i) wch[i] wch i w.charAt(i) w.charAt w i if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      } wch[i] >= 'A' && wch[i] <= 'Z' wch[i] >= 'A' wch[i] wch i 'A' wch[i] <= 'Z' wch[i] wch i 'Z' {
        wch[i] += 'a' - 'A';
      } wch[i] += 'a' - 'A' wch[i] wch i 'a' - 'A' 'a' 'A' for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    } ; {
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    } {
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    } t = sc.next() t sc.next() sc.next sc if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      } "END_OF_TEXT".equals(t) "END_OF_TEXT".equals "END_OF_TEXT" t {
        break;
      } break; {
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      } tm = t.length() tm t.length() t.length t tch = new char[tm] tch new char[tm] tm for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        } i = 0; i = 0 i 0 i < tm i tm i++ i++ i {
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        } {
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        } tch[i] = t.charAt(i) tch[i] tch i t.charAt(i) t.charAt t i if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          } tch[i] >= 'A' && tch[i] <= 'Z' tch[i] >= 'A' tch[i] tch i 'A' tch[i] <= 'Z' tch[i] tch i 'Z' {
            tch[i] += 'a' - 'A';
          } tch[i] += 'a' - 'A' tch[i] tch i 'a' - 'A' 'a' 'A' if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        } wm == tm wm tm {
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        } for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          } i = 0; i = 0 i 0 i < tm i tm i++ i++ i {
            if(wch[i] != tch[i])break;
          } {
            if(wch[i] != tch[i])break;
          } if(wch[i] != tch[i])break; wch[i] != tch[i] wch[i] wch i tch[i] tch i break; if(i == tm)count++; i == tm i tm count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc java.io.InputStream in in java.io.PrintStream out out public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  } main {
    (new Main()).run(System.in, System.out);
  } (new Main()).run(System.in, System.out) (new Main()).run (new Main()) System.in System System.in System.out System System.out String[] args args public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String w, t;
    int count, i, wm, tm;
    char[] wch, tch;

    count = 0;
    w = sc.next();
    wm = w.length();
    wch = new char[wm];
    for(i = 0;i < wm;i++){
      wch[i] = w.charAt(i);
      if(wch[i] >= 'A' && wch[i] <= 'Z'){
        wch[i] += 'a' - 'A';
      }
    }

    for(;;){
      t = sc.next();
      if("END_OF_TEXT".equals(t)){
        break;
      }else{
        tm = t.length();
        tch = new char[tm];
        for(i = 0;i < tm;i++){
          tch[i] = t.charAt(i);
          if(tch[i] >= 'A' && tch[i] <= 'Z'){
            tch[i] += 'a' - 'A';
          }
        }

        if(wm == tm){
          for(i = 0;i < tm;i++){
            if(wch[i] != tch[i])break;
          }
          if(i == tm)count++;
        }
      }
    }

    System.out.println(count);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}