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

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    }

} Main public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    } main {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    } try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        } {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String line line store=""; store "" boolean first=true; first true int sum=0; sum 0 while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            } if(line.equals("END_OF_TEXT"))break; line.equals("END_OF_TEXT") line.equals line "END_OF_TEXT" break; if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	} first {
            		store=line.toLowerCase();
            		first=false;
            	} store=line.toLowerCase() store line.toLowerCase() line.toLowerCase line first=false first false {
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	} String[] str = line.split(" "); str line.split(" ") line.split line " " for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		} {
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		} if(store.equals(str[i].toLowerCase())){
            				sum++;
            			} store.equals(str[i].toLowerCase()) store.equals store str[i].toLowerCase() str[i].toLowerCase str[i] str i {
            				sum++;
            			} sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    }

} public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    }

}