import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java import java.util.regex.*; regex.* java.util public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int count = 0; count 0 String target = br.readLine().toLowerCase(); target br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        } true {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        } String line = br.readLine(); line br.readLine() br.readLine br String[] line2 = line.split(" "); line2 line.split(" ") line.split line " " if(line2[0].equals("END_OF_TEXT"))break; line2[0].equals("END_OF_TEXT") line2[0].equals line2[0] line2 0 "END_OF_TEXT" break; for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            } int i=0; int i=0; i 0 i<line2.length i line2.length line2 line2.length i++ i++ i {
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            } {
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            } String s= line2[i].toLowerCase(); s line2[i].toLowerCase() line2[i].toLowerCase line2[i] line2 i if(s.equals(target))count++; s.equals(target) s.equals s target 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 Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0;
        String target = br.readLine().toLowerCase();
        while(true) {
            String line = br.readLine();
            String[] line2 = line.split(" ");
            if(line2[0].equals("END_OF_TEXT"))break;
            for(int i=0;i<line2.length;i++){
                String s= line2[i].toLowerCase();
                if(s.equals(target))count++;
            }
        }
        System.out.println(count);
    }
}