import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    int[] count = new int[26];
 
    public void run() {
        String s=sc.nextLine().toLowerCase();
        int count=0;
        while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        }
        ln(count);
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
} import java.util.Scanner; Scanner java.util class Main {
    Scanner sc = new Scanner(System.in);
 
    int[] count = new int[26];
 
    public void run() {
        String s=sc.nextLine().toLowerCase();
        int count=0;
        while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        }
        ln(count);
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] count = new int[26]; count new int[26] 26 public void run() {
        String s=sc.nextLine().toLowerCase();
        int count=0;
        while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        }
        ln(count);
    } run {
        String s=sc.nextLine().toLowerCase();
        int count=0;
        while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        }
        ln(count);
    } String s=sc.nextLine().toLowerCase(); s sc.nextLine().toLowerCase() sc.nextLine().toLowerCase sc.nextLine() sc.nextLine sc int count=0; count 0 while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        } true {
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        } String str=sc.next(); str sc.next() sc.next sc if(s.equals(str.toLowerCase()))count++; s.equals(str.toLowerCase()) s.equals s str.toLowerCase() str.toLowerCase str count++ count if("END_OF_TEXT".equals(str))break; "END_OF_TEXT".equals(str) "END_OF_TEXT".equals "END_OF_TEXT" str break; ln(count) ln count public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args public static void pr(Object o) {
        System.out.print(o);
    } pr {
        System.out.print(o);
    } System.out.print(o) System.out.print System.out System System.out o Object o o public static void ln(Object o) {
        System.out.println(o);
    } ln {
        System.out.println(o);
    } System.out.println(o) System.out.println System.out System System.out o Object o o public static void ln() {
        System.out.println();
    } ln {
        System.out.println();
    } System.out.println() System.out.println System.out System System.out
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    int[] count = new int[26];
 
    public void run() {
        String s=sc.nextLine().toLowerCase();
        int count=0;
        while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        }
        ln(count);
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}
