import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	} run {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String w = scan.next(); w scan.next() scan.next scan w = w.toLowerCase() w w.toLowerCase() w.toLowerCase w int wcount = 0; wcount 0 while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		} true {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		} String t = scan.nextLine(); t scan.nextLine() scan.nextLine scan if(t.equals("END_OF_TEXT")) break; t.equals("END_OF_TEXT") t.equals t "END_OF_TEXT" break; String[] tarray = t.split(" "); tarray t.split(" ") t.split t " " for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			} String s tarray {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			} {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			} s = s.toLowerCase() s s.toLowerCase() s.toLowerCase s if (w.equals(s)) wcount += 1; w.equals(s) w.equals w s wcount += 1 wcount 1 System.out.println(wcount) System.out.println System.out System System.out wcount public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		w = w.toLowerCase();
		int wcount = 0;
		while (true) {
			String t = scan.nextLine();
			if(t.equals("END_OF_TEXT")) break;
			String[] tarray = t.split(" ");
			for ( String s : tarray) {
				s = s.toLowerCase();
				if (w.equals(s)) wcount += 1;
			}
		}
		System.out.println(wcount);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}