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

public class constant_vu {

	public static void main(String[] args) throws IOException {
	    BufferedReader in = new BufferedReader(new FileReader("constant.in"));
		PrintWriter out = new PrintWriter(new File("constant.out"));
		
		int n = Integer.parseInt(in.readLine());
		String[] r = new String[n];

		for (int i = 0; i < n; i++) {
			char[] p = in.readLine().toCharArray();
			r[i] = "";
			StringBuilder sb = new StringBuilder();
			for (char c : p) {
				if (c != ' ') {
					//r[i] += c;
					sb.append(c);
					//setCharAt
				}
			}
			r[i] = sb.toString();
		}

		int ans = 0;
		String t = in.readLine();
		for (String h : r) {
			if (t.equals(h)) {
				ans++;
			}
		}

		out.println(ans);

		in.close();
		out.close();
	}

}