import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		}
	}

		

	 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		}
	} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		} main {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String w = scan.next(); w scan.next() scan.next scan String lw = w.toLowerCase(); lw w.toLowerCase() w.toLowerCase w String sw[] = lw.split(""); sw lw.split("") lw.split lw "" int i i m m t t ti; ti ti = 0 ti 0 for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			} ; {
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			} {
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			} String s = scan.next(); s scan.next() scan.next scan String ls = s.toLowerCase(); ls s.toLowerCase() s.toLowerCase s String ss[] = ls.split(""); ss ls.split("") ls.split ls "" if(s.equals("END_OF_TEXT"))
				break; s.equals("END_OF_TEXT") s.equals s "END_OF_TEXT" break; t = 0 t 0 for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				} m = 0; m = 0 m 0 m < w.length() m w.length() w.length w m++ m++ m {
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				} {
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				} if(s.length() < w.length() || s.length() != w.length())
					break; s.length() < w.length() || s.length() != w.length() s.length() < w.length() s.length() s.length s w.length() w.length w s.length() != w.length() s.length() s.length s w.length() w.length w break; if(ss[m].equals(sw[m]))
					t++; ss[m].equals(sw[m]) ss[m].equals ss[m] ss m sw[m] sw m t++ t if(t == w.length())
					ti++; t == w.length() t w.length() w.length w ti++ ti System.out.println(ti) System.out.println System.out System System.out ti String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		}
	} public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		}
	} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		}
	}

		

	