import java.util.*;
import java.io.*;

public class constant_af implements Runnable {
	public static void main(String[] args) {
		new Thread(new constant_af()).start();
	}
	
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof;
	
	public void run() {
		try {
			Locale.setDefault(Locale.US);
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
		} catch (IOException e) {
		} finally {
			out.close();
		}
	}
	
	String nextToken() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch(IOException e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}
	
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
	
	long nextLong() {
		return Long.parseLong(nextToken());
	}
	
	double parseDouble() {
		return Double.parseDouble(nextToken());
	}
	
	String FNAME = "constant";
	
	void myAssert(boolean e, String msg) { 
		if (!e) {
			throw new Error(msg);
		}
	}
	
	public void solve() throws IOException {
		int n = nextInt();
		myAssert(1 <= n && n <= 1000, "n is too big");
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = br.readLine();
			myAssert(a[i].length() > 0, "No symbols at line " + (i + 2));
			myAssert(a[i].length() == a[i].trim().length(), "Space - symbols at line " + (i + 2));
			myAssert(a[i].length() <= 1024, "Line " + (i + 2) + " contains too many symbols");
			StringBuilder ts = new StringBuilder();
			for (int j = 0; j < a[i].length(); j++) {
				myAssert('a' <= a[i].charAt(j) && a[i].charAt(j) <= 'z' || a[i].charAt(j) == ' ',
						 "Bad symbol at line " + (i + 2) + " at position" + (j + 1));
				if ('a' <= a[i].charAt(j) && a[i].charAt(j) <= 'z') {
					ts.append(a[i].charAt(j));
				}
			}
			a[i] = ts.toString();
		}
		
		String s = br.readLine();
		myAssert(s.length() > 0, "No symbols at line " + (n + 2));
		myAssert(s.length() == s.trim().length(), "Space - symbols at line " + (n + 2));
		myAssert(s.length() <= 1024, "Line " + (n + 1) + " contains too many symbols");

		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (s.equals(a[i])) {
				ans++;
			}
		}
		
		myAssert(ans != 0, "No author found!!");
		
		out.println(ans);
	}
	
}
