import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	}

} Main public static Scanner sc; sc public static void main(String[] args){
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	} main {
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	} sc=new Scanner(System.in) sc new Scanner(System.in) String W=sc.next() W sc.next() sc.next sc T; T int ans=0; ans 0 while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		} true {
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		} T=sc.next() T sc.next() sc.next sc if(T.equals("END_OF_TEXT"))break; T.equals("END_OF_TEXT") T.equals T "END_OF_TEXT" break; if(T.equalsIgnoreCase(W))ans++; T.equalsIgnoreCase(W) T.equalsIgnoreCase T W ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	}

} public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	}

} Main
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		String W=sc.next(),T;
		int ans=0;
		while(true){
			T=sc.next();
			if(T.equals("END_OF_TEXT"))break;
			if(T.equalsIgnoreCase(W))ans++;
		}
		System.out.println(ans);
	}

}