import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next().toLowerCase(); s sc.next().toLowerCase() sc.next().toLowerCase sc.next() sc.next sc char c[] = s.toCharArray(); c s.toCharArray() s.toCharArray s String tmp; tmp int cnt=0; cnt 0 boolean bool; bool while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		} !(tmp=sc.next()).equals("END_OF_TEXT") (tmp=sc.next()).equals("END_OF_TEXT") (tmp=sc.next()).equals (tmp=sc.next()) tmp sc.next() sc.next sc "END_OF_TEXT" {
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		} char line[]=tmp.toLowerCase().toCharArray(); line tmp.toLowerCase().toCharArray() tmp.toLowerCase().toCharArray tmp.toLowerCase() tmp.toLowerCase tmp if(line.length!=c.length){
				continue;
			} line.length!=c.length line.length line line.length c.length c c.length {
				continue;
			} continue; bool = true bool true for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			} {
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			} if(c[i]!=line[i]){
					bool=false;
					break;
				} c[i]!=line[i] c[i] c i line[i] line i {
					bool=false;
					break;
				} bool=false bool false break; if(bool){
				cnt++;
			} bool {
				cnt++;
			} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next().toLowerCase();
		char c[] = s.toCharArray();
		String tmp;
		int cnt=0;
		boolean bool;
		while(!(tmp=sc.next()).equals("END_OF_TEXT")){
			char line[]=tmp.toLowerCase().toCharArray();
			if(line.length!=c.length){
				continue;
			}
			bool = true;
			for(int i=0;i<s.length();i++){
				if(c[i]!=line[i]){
					bool=false;
					break;
				}
			}
			if(bool){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}
