import java.util.*;
import java.io.*;

class Main {
  public static void main(String args[]) {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} import java.util.*; util.* java import java.io.*; io.* java class Main {
  public static void main(String args[]) {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
} Main public static void main(String args[]) {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } catch (IOException e) {
      e.printStackTrace();
    }
  } main {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } catch (IOException e) {
      e.printStackTrace();
    }
  } try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } IOException e {
      e.printStackTrace();
    } e.printStackTrace() e.printStackTrace e {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String w = br.readLine(); w br.readLine() br.readLine br String l; l List<String> t = new ArrayList<String>(); t new ArrayList<String>() while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      } !(l = br.readLine()).equals("END_OF_TEXT") (l = br.readLine()).equals("END_OF_TEXT") (l = br.readLine()).equals (l = br.readLine()) l br.readLine() br.readLine br "END_OF_TEXT" {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      } for (String in : l.split(" ")) {
          t.add(in);
        } String in l.split(" ") l.split l " " {
          t.add(in);
        } {
          t.add(in);
        } t.add(in) t.add t in int ans = 0; ans 0 for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      } String str t {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      } {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      } if (str.equalsIgnoreCase(w)) {
          ans++;
        } str.equalsIgnoreCase(w) str.equalsIgnoreCase str w {
          ans++;
        } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;
import java.io.*;

class Main {
  public static void main(String args[]) {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String l;
      List<String> t = new ArrayList<String>();
      while (!(l = br.readLine()).equals("END_OF_TEXT")) {
        for (String in : l.split(" ")) {
          t.add(in);
        }  
      }
      int ans = 0;
      for (String str : t) {
        if (str.equalsIgnoreCase(w)) {
          ans++;
        }
      }
      System.out.println(ans);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}