import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    } main {
        Main main = new Main();
        main.solv();
    } Main main = new Main(); main new Main() main.solv() main.solv main String[] args args private void solv() {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    } solv {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) String W = input.next(); W input.next() input.next input int count = 0; count 0 while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        } true {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        } String T = input.next(); T input.next() input.next input if ("END_OF_TEXT".equals(T)) break; "END_OF_TEXT".equals(T) "END_OF_TEXT".equals "END_OF_TEXT" T break; if (W.equalsIgnoreCase(T)) count++; W.equalsIgnoreCase(T) W.equalsIgnoreCase W T count++ count System.out.println(count) System.out.println System.out System System.out count public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    }
} public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    }
} Main
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        String W = input.next();
        int count = 0;
        while (true) {
            String T = input.next();
            if ("END_OF_TEXT".equals(T)) break;
            if (W.equalsIgnoreCase(T)) count++;
        }
        System.out.println(count);
    }
}