import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	}

	static int binSearch(int[] array, int n, int[] array1, int m) {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	}

	static int binSearch(int[] array, int n, int[] array1, int m) {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	}
} Main public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] S = new int[n]; S new int[n] n for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			S[i] = sc.nextInt();
		} {
			S[i] = sc.nextInt();
		} S[i] = sc.nextInt() S[i] S i sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] T = new int[m]; T new int[m] m for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		} int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
			T[j] = sc.nextInt();
		} {
			T[j] = sc.nextInt();
		} T[j] = sc.nextInt() T[j] T j sc.nextInt() sc.nextInt sc System.out.println(binSearch(S, n, T, m)) System.out.println System.out System System.out binSearch(S, n, T, m) binSearch S n T m String[] args args static int binSearch(int[] array, int n, int[] array1, int m) {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	} binSearch {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	} int count = 0; count 0 for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		} {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		} int key = array1[i]; key array1[i] array1 i int pl = 0; pl 0 int pr = n - 1; pr n - 1 n 1 do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr); pl <= pr pl pr {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} int pc = (pr + pl) / 2; pc (pr + pl) / 2 (pr + pl) pr pl 2 if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			} array[pc] == key array[pc] array pc key {
				count++;
				break;
			} count++ count break; if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			} array[pc] < key array[pc] array pc key {
				pl = pc + 1;
			} pl = pc + 1 pl pc + 1 pc 1 {
				pr = pc - 1;
			} pr = pc - 1 pr pc - 1 pc 1 return count; count int[] array array int n n int[] array1 array1 int m m public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	}

	static int binSearch(int[] array, int n, int[] array1, int m) {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	}
} public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	}

	static int binSearch(int[] array, int n, int[] array1, int m) {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] T = new int[m];
		for (int j = 0; j < m; j++) {
			T[j] = sc.nextInt();
		}
	System.out.println(binSearch(S, n, T, m));
	}

	static int binSearch(int[] array, int n, int[] array1, int m) {
		int count = 0;
		for (int i = 0; i < m; i++) {
			int key = array1[i];
			int pl = 0;
			int pr = n - 1;
			do {
				int pc = (pr + pl) / 2;
			if (array[pc] == key) {
				count++;
				break;
			} else if (array[pc] < key){
				pl = pc + 1;
			} else {
				pr = pc - 1;
			}
			} while (pl <= pr);
		}
		return count;
	}
}
