import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		String w=scan.next();
		int cnt=0;
		
		while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		}
		
		System.out.println(cnt);
		
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		String w=scan.next();
		int cnt=0;
		
		while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		}
		
		System.out.println(cnt);
		
	}
} Main public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		String w=scan.next();
		int cnt=0;
		
		while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		}
		
		System.out.println(cnt);
		
	} main {
		Scanner scan=new Scanner(System.in);
		
		String w=scan.next();
		int cnt=0;
		
		while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		}
		
		System.out.println(cnt);
		
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String w=scan.next(); w scan.next() scan.next scan int cnt=0; cnt 0 while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		} scan.hasNext() scan.hasNext scan {
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		} String s=scan.next(); s scan.next() scan.next scan if(s.equals("END_OF_TEXT"))
				break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; s=s.toLowerCase() s s.toLowerCase() s.toLowerCase s if(s.equals(w))
				cnt++; s.equals(w) s.equals s w cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		String w=scan.next();
		int cnt=0;
		
		while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		}
		
		System.out.println(cnt);
		
	}
}
