// ITP1_9_A Finding a Word
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String W;
      String T;
      int cnt = 0;

      try {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      }

      catch (Exception e) {
         System.err.println(e);
      }

   }
} import java.io.*; io.* java class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String W;
      String T;
      int cnt = 0;

      try {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      }

      catch (Exception e) {
         System.err.println(e);
      }

   }
} Main public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String W;
      String T;
      int cnt = 0;

      try {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      }

      catch (Exception e) {
         System.err.println(e);
      }

   } main {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String W;
      String T;
      int cnt = 0;

      try {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      }

      catch (Exception e) {
         System.err.println(e);
      }

   } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W; W String T; T int cnt = 0; cnt 0 try {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      }

      catch (Exception e) {
         System.err.println(e);
      } catch (Exception e) {
         System.err.println(e);
      } Exception e {
         System.err.println(e);
      } System.err.println(e) System.err.println System.err System System.err e {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      } W = br.readLine() W br.readLine() br.readLine br T = br.readLine() T br.readLine() br.readLine br while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         } !(T.equals("END_OF_TEXT")) (T.equals("END_OF_TEXT")) T.equals T "END_OF_TEXT" { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         } String[] Ti = T.split(" "); Ti T.split(" ") T.split T " " for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            } int i = 0; int i = 0; i 0 i < Ti.length i Ti.length Ti Ti.length i++ i++ i {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            } {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            } if (Ti[i].equalsIgnoreCase(W))
                  cnt++; Ti[i].equalsIgnoreCase(W) Ti[i].equalsIgnoreCase Ti[i] Ti i W cnt++ cnt T = br.readLine() T br.readLine() br.readLine br System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args
// ITP1_9_A Finding a Word
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String W;
      String T;
      int cnt = 0;

      try {
         W = br.readLine();
         T = br.readLine();
         while (!(T.equals("END_OF_TEXT"))) { 
            String[] Ti = T.split(" ");
            for (int i = 0; i < Ti.length; i++) {
               if (Ti[i].equalsIgnoreCase(W))
                  cnt++;
            }
            T = br.readLine();
         }
         System.out.println(cnt);
      }

      catch (Exception e) {
         System.err.println(e);
      }

   }
}