import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	}
	
	public static boolean sortedCheck(int[] nums) {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	}
	
	public static int[] stringToIntArray(String str, int len) {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	}
	
	public static int binarySearch(int[] sorted, int x, int start, int end) {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	}
	
	public static boolean sortedCheck(int[] nums) {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	}
	
	public static int[] stringToIntArray(String str, int len) {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	}
	
	public static int binarySearch(int[] sorted, int x, int start, int end) {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] str = new String[4]; str new String[4] 4 for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		} int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
			str[i] = sc.nextLine();
		} {
			str[i] = sc.nextLine();
		} str[i] = sc.nextLine() str[i] str i sc.nextLine() sc.nextLine sc sc.close() sc.close sc int lenSort = Integer.parseInt(str[0]); lenSort Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int[] sorted = stringToIntArray(str[1], lenSort); sorted stringToIntArray(str[1], lenSort) stringToIntArray str[1] str 1 lenSort int lenUn = Integer.parseInt(str[2]); lenUn Integer.parseInt(str[2]) Integer.parseInt Integer str[2] str 2 int[] unsorted = stringToIntArray(str[3], lenUn); unsorted stringToIntArray(str[3], lenUn) stringToIntArray str[3] str 3 lenUn if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		} sortedCheck(sorted) sortedCheck sorted {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		} int n = 0; n 0 for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			} int u unsorted {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			} {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			} if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				} binarySearch(sorted, u, 0, sorted.length - 1) > 0 binarySearch(sorted, u, 0, sorted.length - 1) binarySearch sorted u 0 sorted.length - 1 sorted.length sorted sorted.length 1 0 {
					n++;
				} n++ n System.out.println(n) System.out.println System.out System System.out n String[] args args public static boolean sortedCheck(int[] nums) {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	} sortedCheck {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	} int n = nums[0]; n nums[0] nums 0 for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		} int i nums {
			if(n <= i) {
				n = i;
			}
			else return false;
		} {
			if(n <= i) {
				n = i;
			}
			else return false;
		} if(n <= i) {
				n = i;
			}
			else return false; n <= i n i {
				n = i;
			} n = i n i return false; false return true; true int[] nums nums public static int[] stringToIntArray(String str, int len) {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	} stringToIntArray {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	} String[] strings = str.split(" ", len); strings str.split(" ", len) str.split str " " len int[] nums = new int[strings.length]; nums new int[strings.length] strings.length strings strings.length for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		} int i = 0; int i = 0; i 0 i < strings.length i strings.length strings strings.length i++ i++ i {
			nums[i] = Integer.parseInt(strings[i]);
		} {
			nums[i] = Integer.parseInt(strings[i]);
		} nums[i] = Integer.parseInt(strings[i]) nums[i] nums i Integer.parseInt(strings[i]) Integer.parseInt Integer strings[i] strings i return nums; nums String str str int len len public static int binarySearch(int[] sorted, int x, int start, int end) {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	} binarySearch {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	} if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		} start <= end start end {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		} int mid = (start + end) / 2; mid (start + end) / 2 (start + end) start end 2 if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end); sorted[mid] == x sorted[mid] sorted mid x return 1; 1 if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end); sorted[mid] > x sorted[mid] sorted mid x return binarySearch(sorted, x, start, mid - 1); binarySearch(sorted, x, start, mid - 1) binarySearch sorted x start mid - 1 mid 1 return binarySearch(sorted, x, mid + 1, end); binarySearch(sorted, x, mid + 1, end) binarySearch sorted x mid + 1 mid 1 end return -1; -1 1 int[] sorted sorted int x x int start start int end end public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	}
	
	public static boolean sortedCheck(int[] nums) {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	}
	
	public static int[] stringToIntArray(String str, int len) {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	}
	
	public static int binarySearch(int[] sorted, int x, int start, int end) {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	}
	
	public static boolean sortedCheck(int[] nums) {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	}
	
	public static int[] stringToIntArray(String str, int len) {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	}
	
	public static int binarySearch(int[] sorted, int x, int start, int end) {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = new String[4];
		for(int i = 0; i < str.length; i++) {
			str[i] = sc.nextLine();
		}
		sc.close();
		int lenSort = Integer.parseInt(str[0]);
		int[] sorted = stringToIntArray(str[1], lenSort);
		int lenUn = Integer.parseInt(str[2]);
		int[] unsorted = stringToIntArray(str[3], lenUn);
		if (sortedCheck(sorted)) {
			int n = 0;
			for(int u: unsorted) {
				if (binarySearch(sorted, u, 0, sorted.length - 1) > 0) {
					n++;
				}
			}
			System.out.println(n);
		}
	}
	
	public static boolean sortedCheck(int[] nums) {
		int n = nums[0];
		for(int i: nums) {
			if(n <= i) {
				n = i;
			}
			else return false;
		}
		return true;
	}
	
	public static int[] stringToIntArray(String str, int len) {
		String[] strings = str.split(" ", len);
		int[] nums = new int[strings.length];
		for(int i = 0; i < strings.length; i++) {
			nums[i] = Integer.parseInt(strings[i]);
		}
		return nums;
	}
	
	public static int binarySearch(int[] sorted, int x, int start, int end) {
		if (start <= end) {
			int mid = (start + end) / 2;
			if (sorted[mid] == x)
				return 1;
			else if (sorted[mid] > x)
				return binarySearch(sorted, x, start, mid - 1);
			else
				return binarySearch(sorted, x, mid + 1, end);
		}
		return -1;
	}
}

