Problem:
Search I

You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.

Output

Print C in a line.

Constraints

n ≤ 10000

q ≤ 500

0 ≤ an element in S ≤ 109

0 ≤ an element in T ≤ 109

Sample Input 1

5
1 2 3 4 5
3
3 4 1

Sample Output 1

3

Sample Input 2

3
3 1 2
1
5

Sample Output 2

0

Sample Input 3

5
1 1 2 2 3
2
1 2

Sample Output 3

2

Notes

Solution in JAVA (judge verdict: Accepted)

import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner scin = new Scanner(System.in);
		int num_list_length = Integer.parseInt(scin.nextLine());
		int[] searchable_nums = new int[num_list_length];
		String[] unparsed_nums = scin.nextLine().split(" ");
		for (int i = 0; i < unparsed_nums.length; i++) {
			searchable_nums[i] = Integer.parseInt(unparsed_nums[i]);
		}
		
		num_list_length = Integer.parseInt(scin.nextLine());
		int[] query = new int[num_list_length];
		unparsed_nums = scin.nextLine().split(" ");
		for (int i = 0; i < unparsed_nums.length; i++) {
			query[i] = Integer.parseInt(unparsed_nums[i]);
		}
		
		System.out.println(searchNumsLinear(searchable_nums, query));
	}
	
	public static int searchNumsLinear(int[] nums, int[] query) {
		boolean[] found = new boolean[query.length];
		for (int i = 0; i < nums.length; i ++) {
			int tgtnum = nums[i];
			for (int j = 0; j < query.length; j++) {
				if (found[j]) {
					continue;
				}
				if (query[j] == tgtnum){
					found[j] = true;
				}
			}
		}
		
		int ct = 0;
		for (int i = 0; i < found.length; i++) {
			if (found[i]) {
				ct += 1;
			}
		}
		return ct;
	}
}