import java.util.Scanner;

class Solve{
	public int s[];
	public int t[];
	public int count;
	public void binary(int left,int right,int num){
		int mid = (left + right) / 2;
		if(right - left <= 1) {
			if(s[right] == num || s[left] == num) count++;
		}
		else if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num);
	}
}

class Main{//一部全探索の問題のコードを使用
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		Solve sv = new Solve();
		//prepare s
		int n = sc.nextInt();
		sv.s = new int[n];
		for(int i = 0;i < n;i++) {
			sv.s[i] = sc.nextInt();
		}
		//prepare t
		int q = sc.nextInt();
		sv.t = new int[q];
		for(int i = 0;i < q;i++) {
			sv.t[i] = sc.nextInt();
		}
		//find and count
		sv.count = 0;
		for(int i = 0;i < q;i++) {
			sv.binary(0,n - 1,sv.t[i]);
		}
		//print
		System.out.printf("%d\n",sv.count);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util class Solve{
	public int s[];
	public int t[];
	public int count;
	public void binary(int left,int right,int num){
		int mid = (left + right) / 2;
		if(right - left <= 1) {
			if(s[right] == num || s[left] == num) count++;
		}
		else if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num);
	}
} Solve public int s[]; s public int t[]; t public int count; count public void binary(int left,int right,int num){
		int mid = (left + right) / 2;
		if(right - left <= 1) {
			if(s[right] == num || s[left] == num) count++;
		}
		else if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num);
	} binary {
		int mid = (left + right) / 2;
		if(right - left <= 1) {
			if(s[right] == num || s[left] == num) count++;
		}
		else if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num);
	} int mid = (left + right) / 2; mid (left + right) / 2 (left + right) left right 2 if(right - left <= 1) {
			if(s[right] == num || s[left] == num) count++;
		}
		else if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num); right - left <= 1 right - left right left 1 {
			if(s[right] == num || s[left] == num) count++;
		} if(s[right] == num || s[left] == num) count++; s[right] == num || s[left] == num s[right] == num s[right] s right num s[left] == num s[left] s left num count++ count if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num); s[mid] == num s[mid] s mid num count++ count if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num); s[mid] < num s[mid] s mid num binary(mid,right,num) binary mid right num binary(left,mid,num) binary left mid num int left left int right right int num num class Main{//一部全探索の問題のコードを使用
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		Solve sv = new Solve();
		//prepare s
		int n = sc.nextInt();
		sv.s = new int[n];
		for(int i = 0;i < n;i++) {
			sv.s[i] = sc.nextInt();
		}
		//prepare t
		int q = sc.nextInt();
		sv.t = new int[q];
		for(int i = 0;i < q;i++) {
			sv.t[i] = sc.nextInt();
		}
		//find and count
		sv.count = 0;
		for(int i = 0;i < q;i++) {
			sv.binary(0,n - 1,sv.t[i]);
		}
		//print
		System.out.printf("%d\n",sv.count);
		sc.close();
	}
} Main public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		Solve sv = new Solve();
		//prepare s
		int n = sc.nextInt();
		sv.s = new int[n];
		for(int i = 0;i < n;i++) {
			sv.s[i] = sc.nextInt();
		}
		//prepare t
		int q = sc.nextInt();
		sv.t = new int[q];
		for(int i = 0;i < q;i++) {
			sv.t[i] = sc.nextInt();
		}
		//find and count
		sv.count = 0;
		for(int i = 0;i < q;i++) {
			sv.binary(0,n - 1,sv.t[i]);
		}
		//print
		System.out.printf("%d\n",sv.count);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		Solve sv = new Solve();
		//prepare s
		int n = sc.nextInt();
		sv.s = new int[n];
		for(int i = 0;i < n;i++) {
			sv.s[i] = sc.nextInt();
		}
		//prepare t
		int q = sc.nextInt();
		sv.t = new int[q];
		for(int i = 0;i < q;i++) {
			sv.t[i] = sc.nextInt();
		}
		//find and count
		sv.count = 0;
		for(int i = 0;i < q;i++) {
			sv.binary(0,n - 1,sv.t[i]);
		}
		//print
		System.out.printf("%d\n",sv.count);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Solve sv = new Solve(); sv new Solve() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc sv.s = new int[n] sv.s sv sv.s new int[n] n for(int i = 0;i < n;i++) {
			sv.s[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			sv.s[i] = sc.nextInt();
		} {
			sv.s[i] = sc.nextInt();
		} sv.s[i] = sc.nextInt() sv.s[i] sv.s sv sv.s i sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc sv.t = new int[q] sv.t sv sv.t new int[q] q for(int i = 0;i < q;i++) {
			sv.t[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			sv.t[i] = sc.nextInt();
		} {
			sv.t[i] = sc.nextInt();
		} sv.t[i] = sc.nextInt() sv.t[i] sv.t sv sv.t i sc.nextInt() sc.nextInt sc sv.count = 0 sv.count sv sv.count 0 for(int i = 0;i < q;i++) {
			sv.binary(0,n - 1,sv.t[i]);
		} int i = 0; int i = 0; i 0 i < q i q i++ i++ i {
			sv.binary(0,n - 1,sv.t[i]);
		} {
			sv.binary(0,n - 1,sv.t[i]);
		} sv.binary(0,n - 1,sv.t[i]) sv.binary sv 0 n - 1 n 1 sv.t[i] sv.t sv sv.t i System.out.printf("%d\n",sv.count) System.out.printf System.out System System.out "%d\n" sv.count sv sv.count sc.close() sc.close sc String[] args args
import java.util.Scanner;

class Solve{
	public int s[];
	public int t[];
	public int count;
	public void binary(int left,int right,int num){
		int mid = (left + right) / 2;
		if(right - left <= 1) {
			if(s[right] == num || s[left] == num) count++;
		}
		else if(s[mid] == num) count++;
		else if(s[mid] < num) binary(mid,right,num);
		else binary(left,mid,num);
	}
}

class Main{//一部全探索の問題のコードを使用
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		Solve sv = new Solve();
		//prepare s
		int n = sc.nextInt();
		sv.s = new int[n];
		for(int i = 0;i < n;i++) {
			sv.s[i] = sc.nextInt();
		}
		//prepare t
		int q = sc.nextInt();
		sv.t = new int[q];
		for(int i = 0;i < q;i++) {
			sv.t[i] = sc.nextInt();
		}
		//find and count
		sv.count = 0;
		for(int i = 0;i < q;i++) {
			sv.binary(0,n - 1,sv.t[i]);
		}
		//print
		System.out.printf("%d\n",sv.count);
		sc.close();
	}
}
