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

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
} Main public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        } catch(IOException e) {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        } String word = br.readLine(); word br.readLine() br.readLine br int count = 0; count 0 String line = ""; line "" while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            } true {
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            } line = br.readLine() line br.readLine() br.readLine br if("END_OF_TEXT".equals(line)){
                    break;
                } "END_OF_TEXT".equals(line) "END_OF_TEXT".equals "END_OF_TEXT" line {
                    break;
                } break; String[] arr = line.split("\\s"); arr line.split("\\s") line.split line "\\s" for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                } int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                } {
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                } if(arr[i].toLowerCase().equals(word)){
                        count++;
                    } arr[i].toLowerCase().equals(word) arr[i].toLowerCase().equals arr[i].toLowerCase() arr[i].toLowerCase arr[i] arr i word {
                        count++;
                    } count++ count System.out.println(String.valueOf(count)) System.out.println System.out System System.out String.valueOf(count) String.valueOf String count String[] args args public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
} public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String word = br.readLine();
            int count = 0;
            String line = "";
            
            while(true){
                line = br.readLine();
                if("END_OF_TEXT".equals(line)){
                    break;
                }
                String[] arr = line.split("\\s");
                for(int i=0; i<arr.length; i++){
                    if(arr[i].toLowerCase().equals(word)){
                        count++;
                    }
                }
            }
            
            System.out.println(String.valueOf(count));
            
            
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}
