import java.util.*;

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

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