import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	}
} Main public static final int BIG_NUM  = 2000000000; BIG_NUM 2000000000 public static final int MOD  = 1000000007; MOD 1000000007 public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	} main {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String P = scanner.next().toLowerCase(); P scanner.next().toLowerCase() scanner.next().toLowerCase scanner.next() scanner.next scanner char p[] = P.toCharArray(); p P.toCharArray() P.toCharArray P String tmp; tmp int ans = 0; ans 0 boolean FLG; FLG while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		} !(tmp = scanner.next()).equals("END_OF_TEXT") (tmp = scanner.next()).equals("END_OF_TEXT") (tmp = scanner.next()).equals (tmp = scanner.next()) tmp scanner.next() scanner.next scanner "END_OF_TEXT" {

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		} char line[] = tmp.toLowerCase().toCharArray(); line tmp.toLowerCase().toCharArray() tmp.toLowerCase().toCharArray tmp.toLowerCase() tmp.toLowerCase tmp if(line.length != p.length)continue; line.length != p.length line.length line line.length p.length p p.length continue; FLG = true FLG true for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			} int i = 0; int i = 0; i 0 i < P.length() i P.length() P.length P i++ i++ i {
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			} {
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			} if(p[i] != line[i]){
					FLG = false;
					break;
				} p[i] != line[i] p[i] p i line[i] line i {
					FLG = false;
					break;
				} FLG = false FLG false break; if(FLG)ans++; FLG ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	}
} public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	}
}
