import java.util.*;

public class Main {
	
	public static int totalMatches(int[] array, int[] array2) {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	}
	
	public static boolean Binarysearch( int[] array,  int search) {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	}
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	}
	
}
 import java.util.*; util.* java public class Main {
	
	public static int totalMatches(int[] array, int[] array2) {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	}
	
	public static boolean Binarysearch( int[] array,  int search) {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	}
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	}
	
} Main public static int totalMatches(int[] array, int[] array2) {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	} totalMatches {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	} int total=0; total 0 for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		} int i = 0; int i = 0; i 0 i < array2.length i array2.length array2 array2.length i++ i++ i {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		} {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		} if (Binarysearch(array, array2[i])) {
				total++;
			} Binarysearch(array, array2[i]) Binarysearch array array2[i] array2 i {
				total++;
			} total++ total return total; total int[] array array int[] array2 array2 public static boolean Binarysearch( int[] array,  int search) {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	} Binarysearch {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	} int left = 0; left 0 int right = array.length - 1; right array.length - 1 array.length array array.length 1 while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		} left <= right left right {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		} int mid = (right+left)/2; mid (right+left)/2 (right+left) right left 2 if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			} array[mid] < search array[mid] array mid search {
				left = mid + 1;
			} left = mid + 1 left mid + 1 mid 1 if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			} array[mid] > search array[mid] array mid search {
				right = mid - 1;
			} right = mid - 1 right mid - 1 mid 1 {
				return true;
			} return true; true return false; false int[] array array int search search public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	} main {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int sizearray = input.nextInt(); sizearray input.nextInt() input.nextInt input int array[] = new int[sizearray]; array new int[sizearray] sizearray for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		} int i = 0; int i = 0; i 0 i < sizearray i sizearray i++ i++ i {
			array[i] = input.nextInt();

		} {
			array[i] = input.nextInt();

		} array[i] = input.nextInt() array[i] array i input.nextInt() input.nextInt input int sizearray2 = input.nextInt(); sizearray2 input.nextInt() input.nextInt input int array2[] = new int[sizearray2]; array2 new int[sizearray2] sizearray2 for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		} int i = 0; int i = 0; i 0 i < sizearray2 i sizearray2 i++ i++ i {
			array2[i] = input.nextInt();

		} {
			array2[i] = input.nextInt();

		} array2[i] = input.nextInt() array2[i] array2 i input.nextInt() input.nextInt input System.out.println(totalMatches(array, array2)) System.out.println System.out System System.out totalMatches(array, array2) totalMatches array array2 input.close() input.close input String[] args args public class Main {
	
	public static int totalMatches(int[] array, int[] array2) {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	}
	
	public static boolean Binarysearch( int[] array,  int search) {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	}
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	}
	
} public class Main {
	
	public static int totalMatches(int[] array, int[] array2) {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	}
	
	public static boolean Binarysearch( int[] array,  int search) {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	}
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	}
	
} Main
import java.util.*;

public class Main {
	
	public static int totalMatches(int[] array, int[] array2) {
		int total=0;
		for (int i = 0; i < array2.length; i++) {
			if (Binarysearch(array, array2[i])) {
				total++;
			}
		}
		return total;
	}
	
	public static boolean Binarysearch( int[] array,  int search) {
		int left = 0;
		int right = array.length - 1;
		
		while ( left <= right) {
			int mid = (right+left)/2;
			if(array[mid] < search) {
				left = mid + 1;
			}
			else if(array[mid] > search) {
				right = mid - 1;
			}
			else {
				return true;
			}
		}
		return false;
		
	}
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int sizearray = input.nextInt();

		int array[] = new int[sizearray];

		for (int i = 0; i < sizearray; i++) {
			array[i] = input.nextInt();

		}
		
		int sizearray2 = input.nextInt();
		int array2[] = new int[sizearray2];
		for (int i = 0; i < sizearray2; i++) {
			array2[i] = input.nextInt();

		}
		System.out.println(totalMatches(array, array2));
		
		input.close();
	}
	
}

