import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) final String word = br.readLine().toUpperCase(); word br.readLine().toUpperCase() br.readLine().toUpperCase br.readLine() br.readLine br int count = 0; count 0 while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        } true {
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        } String line = br.readLine(); line br.readLine() br.readLine br if (line==null|line=="END_OF_TEXT"){
                break;
            } line==null|line=="END_OF_TEXT" line==null line null line=="END_OF_TEXT" line "END_OF_TEXT" {
                break;
            } break; String[] ln = line.split("[.,!\"?:... ]"); ln line.split("[.,!\"?:... ]") line.split line "[.,!\"?:... ]" for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            } int i=0; int i=0; i 0 i<ln.length i ln.length ln ln.length i++ i++ i {
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            } {
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            } String tmp = ln[i].toUpperCase(); tmp ln[i].toUpperCase() ln[i].toUpperCase ln[i] ln i if (tmp.equals(word)){
                    count++;
                } tmp.equals(word) tmp.equals tmp word {
                    count++;
                } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} Main
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String word = br.readLine().toUpperCase();
        int count = 0;
        while (true){
            String line = br.readLine();
            if (line==null|line=="END_OF_TEXT"){
                break;
            }
            String[] ln = line.split("[.,!\"?:... ]");
            for (int i=0; i<ln.length; i++){
                //System.out.println(ln[i]);
                String tmp = ln[i].toUpperCase();
                if (tmp.equals(word)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}