
import java.util.Scanner;

//this implements the bin search which return the position if find, otherwise negative
public class Main {
	public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	}
	
	public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	}
	
	public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	}

} Main public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	} bin_search {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	} int lo = 0; lo 0 int hi = arr.length-1; hi arr.length-1 arr.length arr arr.length 1 while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		} lo <= hi lo hi {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		} if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			} lo == hi lo hi {
				return (arr[lo] == elem)? lo: -1; 
			} return (arr[lo] == elem)? lo: -1; (arr[lo] == elem)? lo: -1 (arr[lo] == elem) arr[lo] arr lo elem lo -1 1 int mid =  lo + (hi - lo) /2; mid lo + (hi - lo) /2 lo (hi - lo) /2 (hi - lo) hi lo 2 if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			} arr[mid]> elem arr[mid] arr mid elem {
				hi = mid;
			} hi = mid hi mid if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			} arr[mid] < elem arr[mid] arr mid elem {
				lo = mid+1;
			} lo = mid+1 lo mid+1 mid 1 {
				return mid;
			} return mid; mid return -1; -1 1 int[] arr arr int elem elem public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	} main {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	} Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int n = cin.nextInt(); n cin.nextInt() cin.nextInt cin int [] S = new int[n]; S new int[n] n for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				S[i] = cin.nextInt();
			} {
				S[i] = cin.nextInt();
			} S[i] = cin.nextInt() S[i] S i cin.nextInt() cin.nextInt cin int  m = cin.nextInt(); m cin.nextInt() cin.nextInt cin int x_i = 0; x_i 0 int count =  0; count 0 for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			} {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			} x_i = cin.nextInt() x_i cin.nextInt() cin.nextInt cin count += (bin_search(S, x_i) >=0)? 1:0 count (bin_search(S, x_i) >=0)? 1:0 (bin_search(S, x_i) >=0) bin_search(S, x_i) bin_search S x_i 0 1 0 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	}
	
	public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	}

} public class Main {
	public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	}
	
	public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	}

} Main

import java.util.Scanner;

//this implements the bin search which return the position if find, otherwise negative
public class Main {
	public static int bin_search(int[] arr, int elem) {
		int lo = 0;
		int hi = arr.length-1;
		
		while(lo <= hi) {
			if(lo == hi) {
				return (arr[lo] == elem)? lo: -1; 
			}
			
			int mid =  lo + (hi - lo) /2;
			if(arr[mid]> elem) {
				hi = mid;
			}else if(arr[mid] < elem) {
				lo = mid+1;
			}else {
				return mid;
			}
			
		}
		
		return -1;
	}
	
	public static void main(String[] args) {
			Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] S = new int[n];
			for(int i = 0; i < n; i++) {
				S[i] = cin.nextInt();
			}
			
			int  m = cin.nextInt();
			int x_i = 0;
			int count =  0;
			for(int i = 0; i < m; i++) {
				x_i = cin.nextInt();
				count += (bin_search(S, x_i) >=0)? 1:0;
			}
			
			
			System.out.println(count);
	}

}