import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	}

} Main public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	} main {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String W = br.readLine().toLowerCase(); W br.readLine().toLowerCase() br.readLine().toLowerCase br.readLine() br.readLine br int ans = 0; ans 0 String line; line while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		} !((line = br.readLine()).equals("END_OF_TEXT")) ((line = br.readLine()).equals("END_OF_TEXT")) (line = br.readLine()).equals (line = br.readLine()) line br.readLine() br.readLine br "END_OF_TEXT" {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		} line = line.toLowerCase() line line.toLowerCase() line.toLowerCase line StringTokenizer st = new StringTokenizer(line, " "); st new StringTokenizer(line, " ") while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			} st.hasMoreTokens() st.hasMoreTokens st {
				if (st.nextToken().equals(W)) ans++;
			} if (st.nextToken().equals(W)) ans++; st.nextToken().equals(W) st.nextToken().equals st.nextToken() st.nextToken st W ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String W = br.readLine().toLowerCase();
		
		int ans = 0;
		String line;
		while (!((line = br.readLine()).equals("END_OF_TEXT"))) {
			line = line.toLowerCase();
			StringTokenizer st = new StringTokenizer(line, " ");
			while (st.hasMoreTokens()) {
				if (st.nextToken().equals(W)) ans++;
			}
		}
		
		System.out.println(ans);
	}

}