import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Arrays;

/*Question
n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°???????????????????????????????????? 
*/

/*Input
???????????? n??????????????? S ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°???????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		//??\???

		int n = Integer.parseInt(br.readLine());
		String[] tmp = br.readLine().split(" ");
		int[] s = new int[n];
		for (int a = 0;a < n;a++){
			s[a] = Integer.parseInt(tmp[a]);
		}
		n = Integer.parseInt(br.readLine());
		tmp = br.readLine().split(" ");
		int[] t = new int[n];
		for (int a = 0;a < n;a++){
			t[a] = Integer.parseInt(tmp[a]);
		}

		//?¨??????¨
		int len; //??????????????????????¨????
		int b = 0;

		//????????¨ - ?????´?????????????????°????¨????
		int count = 0;

		//??´?????????
		Arrays.sort(s);
		Arrays.sort(t);

		/*????????????????????????
		/????????????????????´?????\?????§??¢?´¢??????????????????????????¨??????????????????????????£???
		*/
		for (int a = 0;a < t.length;a++){
			while (b < s.length) {
				if (t[a] < s[b]) {
					break;
				} else if (t[a] == s[b]) {
					count++;
					len = b;
					break;
				}
				b++;
			}
		}

		//??????
		System.out.println(count);
	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz