import java.util.*;
import java.io.*;
import java.util.regex.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String w = br.readLine();	//キーボードで入力された１行目の文字を読み取る
        String t;
        String upper;
        String lower;
        int count = 0;
        int i = 0;
        int j = 0;
        
        while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        }
        System.out.println(count);
     }
} import java.util.*; util.* java import java.io.*; io.* java import java.util.regex.*; regex.* java.util class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String w = br.readLine();	//キーボードで入力された１行目の文字を読み取る
        String t;
        String upper;
        String lower;
        int count = 0;
        int i = 0;
        int j = 0;
        
        while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        }
        System.out.println(count);
     }
} Main public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String w = br.readLine();	//キーボードで入力された１行目の文字を読み取る
        String t;
        String upper;
        String lower;
        int count = 0;
        int i = 0;
        int j = 0;
        
        while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        }
        System.out.println(count);
     } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String w = br.readLine();	//キーボードで入力された１行目の文字を読み取る
        String t;
        String upper;
        String lower;
        int count = 0;
        int i = 0;
        int j = 0;
        
        while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        }
        System.out.println(count);
     } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String w = br.readLine(); w br.readLine() br.readLine br String t; t String upper; upper String lower; lower int count = 0; count 0 int i = 0; i 0 int j = 0; j 0 while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        } (t=br.readLine())!=null (t=br.readLine()) t br.readLine() br.readLine br null {
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        } if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            } "END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000 "END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000 "END_OF_TEXT".equals(t) "END_OF_TEXT".equals "END_OF_TEXT" t w.length()>10 w.length() w.length w 10 t.length()>1000 t.length() t.length t 1000 {
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            } break;                       //END_OF_TEXTが入力されたらwhileを抜ける String[] str = t.split(" "); str t.split(" ") t.split t " " for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            } int k=0; int k=0; k 0 k<str.length k str.length str str.length k++ k++ k {
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            } {
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            } if(str[k].equalsIgnoreCase(w)){
            		count++;
            	} str[k].equalsIgnoreCase(w) str[k].equalsIgnoreCase str[k] str k w {
            		count++;
            	} count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args
import java.util.*;
import java.io.*;
import java.util.regex.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String w = br.readLine();	//キーボードで入力された１行目の文字を読み取る
        String t;
        String upper;
        String lower;
        int count = 0;
        int i = 0;
        int j = 0;
        
        while((t=br.readLine())!=null){
            if("END_OF_TEXT".equals(t) || w.length()>10 || t.length()>1000){
                break;                       //END_OF_TEXTが入力されたらwhileを抜ける
            }
            String[] str = t.split(" ");
            for(int k=0; k<str.length; k++){
            	if(str[k].equalsIgnoreCase(w)){
            		count++;
            	}
            }
        }
        System.out.println(count);
     }
}