import java.util.Scanner;

public class Main {
	
	static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	}
	
    public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
	
	static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	}
	
    public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    }
} Main static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	} binarySearch {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	} int counter = 0; counter 0 int mid = 0; mid 0 for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		} int i=0; int i=0; i 0 i<b.length i b.length b b.length i++ i++ i {
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		} {
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		} int L = 0; L 0 int R = a.length-1; R a.length-1 a.length a a.length 1 while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			} L<=R L R {
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			} mid = (L+R)/2 mid (L+R)/2 (L+R) L R 2 if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				} b[i]==a[mid] b[i] b i a[mid] a mid {
					counter++;
					break;
				} counter++ counter break; if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				} b[i]<a[mid] b[i] b i a[mid] a mid {
					R = mid-1;
				} R = mid-1 R mid-1 mid 1 if(b[i]>a[mid])
				{
					L = mid+1;
				} b[i]>a[mid] b[i] b i a[mid] a mid {
					L = mid+1;
				} L = mid+1 L mid+1 mid 1 return counter; counter int[] a a int[] b b public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    } main {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int num1 = in.nextInt(); num1 in.nextInt() in.nextInt in int intArray1[]; intArray1 intArray1 = new int[num1] intArray1 new int[num1] num1 for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < intArray1.length i intArray1.length intArray1 intArray1.length i++ i++ i {
        	intArray1[i] = in.nextInt();
        } {
        	intArray1[i] = in.nextInt();
        } intArray1[i] = in.nextInt() intArray1[i] intArray1 i in.nextInt() in.nextInt in int num2 = in.nextInt(); num2 in.nextInt() in.nextInt in int intArray2[]; intArray2 intArray2 = new int[num2] intArray2 new int[num2] num2 for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        } int i = 0; int i = 0; i 0 i < intArray2.length i intArray2.length intArray2 intArray2.length i++ i++ i {
        	intArray2[i] = in.nextInt();
        } {
        	intArray2[i] = in.nextInt();
        } intArray2[i] = in.nextInt() intArray2[i] intArray2 i in.nextInt() in.nextInt in int res = binarySearch(intArray1, intArray2); res binarySearch(intArray1, intArray2) binarySearch intArray1 intArray2 System.out.println(res) System.out.println System.out System System.out res in.close() in.close in String argv[] argv public class Main {
	
	static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	}
	
    public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    }
} public class Main {
	
	static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	}
	
    public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    }
} Main
import java.util.Scanner;

public class Main {
	
	static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	}
	
    public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    }
}
