import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	} main {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str=new String(); str new String() String p = new String(); p new String() int count=0; count 0 p = scan.next() p scan.next() scan.next scan while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		} scan.hasNext() scan.hasNext scan {
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		} str =  scan.next() str scan.next() scan.next scan if(str.equals("END_OF_TEXT"))break; str.equals("END_OF_TEXT") str.equals str "END_OF_TEXT" break; if(str.equalsIgnoreCase(p))count++; str.equalsIgnoreCase(p) str.equalsIgnoreCase str p 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) {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	}
} Main
import java.util.Scanner;

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