import java.util.Scanner;

public class Main {
	
	public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	}
	
	public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	}

}
 import java.util.Scanner; Scanner java.util public class Main {
	
	public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	}
	
	public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	}

} Main public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	} search {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	} int mid = low + (high-low)/2; mid low + (high-low)/2 low (high-low)/2 (high-low) high low 2 if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			} high < low high low {
			return false;  // the algorithm has iterated through without finding t
			} return false;  // the algorithm has iterated through without finding t false if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			} S[mid] > t S[mid] S mid t {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			} return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value search(S,t,low,mid-1) search S t low mid-1 mid 1 if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			} S[mid] < t S[mid] S mid t {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			} return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value search(S,t,mid+1,high) search S t mid+1 mid 1 high {  // this means mid = t, so t is in S
			return true;
			} return true; true int[] S S int t t int low low int high high public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	} contains {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	} int counter = 0; counter 0 int low = 0; low 0 int high = S.length - 1; high S.length - 1 S.length S S.length 1 for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		} int t T {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		} {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		} if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			} search(S, t, low, high) search S t low high {  // iterates through each value in T and searches for it in S
				counter++;
			} counter++ counter return counter; counter int[] S S int[] T T public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	} main {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int sizeS = in.nextInt(); sizeS in.nextInt() in.nextInt in int[] S = new int[sizeS]; S new int[sizeS] sizeS for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		} int i = 0; int i = 0; i 0 i < sizeS i sizeS i++ i++ i {
			S[i] = in.nextInt();
		} {
			S[i] = in.nextInt();
		} S[i] = in.nextInt() S[i] S i in.nextInt() in.nextInt in int sizeT = in.nextInt(); sizeT in.nextInt() in.nextInt in int[] T = new int[sizeT]; T new int[sizeT] sizeT for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		} int i = 0; int i = 0; i 0 i < sizeT i sizeT i++ i++ i {
			T[i] = in.nextInt();
		} {
			T[i] = in.nextInt();
		} T[i] = in.nextInt() T[i] T i in.nextInt() in.nextInt in in.close() in.close in int result = contains(S,T); result contains(S,T) contains S T System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	
	public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	}
	
	public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	}

} public class Main {
	
	public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	}
	
	public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	}

} Main
import java.util.Scanner;

public class Main {
	
	public static Boolean search(int[] S, int t, int low, int high) {
		int mid = low + (high-low)/2;  // initializing middle value to search
		if (high < low) {
			return false;  // the algorithm has iterated through without finding t
			}
		if (S[mid] > t) {
			return search(S,t,low,mid-1);  // if t is in S, it'll be in the half of the array less than the middle value
			}
		else if (S[mid] < t) {
			return search(S,t,mid+1,high);  // if t is in S, it'll be in the half of the array greater than the middle value
			}
		else /*(S[mid] == t)*/ {  // this means mid = t, so t is in S
			return true;
			}
	}
	
	public static int contains(int[] S, int[] T) {
		int counter = 0;
		int low = 0;
		int high = S.length - 1;
		for (int t : T) {
			if (search(S, t, low, high)) {  // iterates through each value in T and searches for it in S
				counter++;
			}
		}
		return counter;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sizeS = in.nextInt();
		int[] S = new int[sizeS];
		for (int i = 0; i < sizeS; i++) {
			S[i] = in.nextInt();
		}
		int sizeT = in.nextInt();
		int[] T = new int[sizeT];
		for (int i = 0; i < sizeT; i++) {
			T[i] = in.nextInt();
		}
		in.close();
		int result = contains(S,T);
		System.out.println(result);
	}

}

