import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String W = br.readLine().toLowerCase();
    int count = 0;

    while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    }
    System.out.println(count);
  }
} import java.io.*; io.* java class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String W = br.readLine().toLowerCase();
    int count = 0;

    while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    }
    System.out.println(count);
  }
} Main public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String W = br.readLine().toLowerCase();
    int count = 0;

    while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    }
    System.out.println(count);
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String W = br.readLine().toLowerCase();
    int count = 0;

    while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    }
    System.out.println(count);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W = br.readLine().toLowerCase(); W br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br int count = 0; count 0 while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    } true {
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    } String line = br.readLine(); line br.readLine() br.readLine br if (line.equals("END_OF_TEXT")) {break;} line.equals("END_OF_TEXT") line.equals line "END_OF_TEXT" {break;} break; line = line.toLowerCase() line line.toLowerCase() line.toLowerCase line String[] words = line.split(" "); words line.split(" ") line.split line " " for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      } int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
        if (W.equals(words[i])) {count++;}
      } {
        if (W.equals(words[i])) {count++;}
      } if (W.equals(words[i])) {count++;} W.equals(words[i]) W.equals W words[i] words i {count++;} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String W = br.readLine().toLowerCase();
    int count = 0;

    while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    }
    System.out.println(count);
  }
}