import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int[] S;
	int[] T;
	int i = 0;
	int j = 0;
	int FOUND = 0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_S = br.readLine();//data_and_key
	String str_q = br.readLine();
	String str_T = br.readLine();//key_stack

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);
	S = new int[n+1];//S[n] = key
	T = new int[q];

	Scanner sc_S = new Scanner(str_S).useDelimiter("\\s* \\s*");
	Scanner sc_T = new Scanner(str_T).useDelimiter("\\s* \\s*");

	while(sc_S.hasNext()){
	    S[i] = sc_S.nextInt();
	    i++;
	}

	while(sc_T.hasNext()){
	    T[j] = sc_T.nextInt();
	    j++;
	}

	FOUND = binarySearch(n,S,q,T);

	System.out.println(FOUND);

	sc_S.close();
	sc_T.close();
	
    }

    private static int binarySearch(int n,int S[], int q, int T[]){
	int FOUND_COUNT = 0;
	
	for(int j=0;j<T.length;j++){
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	}
	return FOUND_COUNT;
    }
}
 import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String[] args) throws Exception{
	int[] S;
	int[] T;
	int i = 0;
	int j = 0;
	int FOUND = 0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_S = br.readLine();//data_and_key
	String str_q = br.readLine();
	String str_T = br.readLine();//key_stack

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);
	S = new int[n+1];//S[n] = key
	T = new int[q];

	Scanner sc_S = new Scanner(str_S).useDelimiter("\\s* \\s*");
	Scanner sc_T = new Scanner(str_T).useDelimiter("\\s* \\s*");

	while(sc_S.hasNext()){
	    S[i] = sc_S.nextInt();
	    i++;
	}

	while(sc_T.hasNext()){
	    T[j] = sc_T.nextInt();
	    j++;
	}

	FOUND = binarySearch(n,S,q,T);

	System.out.println(FOUND);

	sc_S.close();
	sc_T.close();
	
    }

    private static int binarySearch(int n,int S[], int q, int T[]){
	int FOUND_COUNT = 0;
	
	for(int j=0;j<T.length;j++){
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	}
	return FOUND_COUNT;
    }
} Main public static void main(String[] args) throws Exception{
	int[] S;
	int[] T;
	int i = 0;
	int j = 0;
	int FOUND = 0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_S = br.readLine();//data_and_key
	String str_q = br.readLine();
	String str_T = br.readLine();//key_stack

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);
	S = new int[n+1];//S[n] = key
	T = new int[q];

	Scanner sc_S = new Scanner(str_S).useDelimiter("\\s* \\s*");
	Scanner sc_T = new Scanner(str_T).useDelimiter("\\s* \\s*");

	while(sc_S.hasNext()){
	    S[i] = sc_S.nextInt();
	    i++;
	}

	while(sc_T.hasNext()){
	    T[j] = sc_T.nextInt();
	    j++;
	}

	FOUND = binarySearch(n,S,q,T);

	System.out.println(FOUND);

	sc_S.close();
	sc_T.close();
	
    } main {
	int[] S;
	int[] T;
	int i = 0;
	int j = 0;
	int FOUND = 0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_S = br.readLine();//data_and_key
	String str_q = br.readLine();
	String str_T = br.readLine();//key_stack

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);
	S = new int[n+1];//S[n] = key
	T = new int[q];

	Scanner sc_S = new Scanner(str_S).useDelimiter("\\s* \\s*");
	Scanner sc_T = new Scanner(str_T).useDelimiter("\\s* \\s*");

	while(sc_S.hasNext()){
	    S[i] = sc_S.nextInt();
	    i++;
	}

	while(sc_T.hasNext()){
	    T[j] = sc_T.nextInt();
	    j++;
	}

	FOUND = binarySearch(n,S,q,T);

	System.out.println(FOUND);

	sc_S.close();
	sc_T.close();
	
    } int[] S; S int[] T; T int i = 0; i 0 int j = 0; j 0 int FOUND = 0; FOUND 0 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str_n = br.readLine(); str_n br.readLine() br.readLine br String str_S = br.readLine(); str_S br.readLine() br.readLine br String str_q = br.readLine(); str_q br.readLine() br.readLine br String str_T = br.readLine(); str_T br.readLine() br.readLine br int n = Integer.parseInt(str_n); n Integer.parseInt(str_n) Integer.parseInt Integer str_n int q = Integer.parseInt(str_q); q Integer.parseInt(str_q) Integer.parseInt Integer str_q S = new int[n+1] S new int[n+1] n+1 n 1 T = new int[q] T new int[q] q Scanner sc_S = new Scanner(str_S).useDelimiter("\\s* \\s*"); sc_S new Scanner(str_S).useDelimiter("\\s* \\s*") new Scanner(str_S).useDelimiter new Scanner(str_S) "\\s* \\s*" Scanner sc_T = new Scanner(str_T).useDelimiter("\\s* \\s*"); sc_T new Scanner(str_T).useDelimiter("\\s* \\s*") new Scanner(str_T).useDelimiter new Scanner(str_T) "\\s* \\s*" while(sc_S.hasNext()){
	    S[i] = sc_S.nextInt();
	    i++;
	} sc_S.hasNext() sc_S.hasNext sc_S {
	    S[i] = sc_S.nextInt();
	    i++;
	} S[i] = sc_S.nextInt() S[i] S i sc_S.nextInt() sc_S.nextInt sc_S i++ i while(sc_T.hasNext()){
	    T[j] = sc_T.nextInt();
	    j++;
	} sc_T.hasNext() sc_T.hasNext sc_T {
	    T[j] = sc_T.nextInt();
	    j++;
	} T[j] = sc_T.nextInt() T[j] T j sc_T.nextInt() sc_T.nextInt sc_T j++ j FOUND = binarySearch(n,S,q,T) FOUND binarySearch(n,S,q,T) binarySearch n S q T System.out.println(FOUND) System.out.println System.out System System.out FOUND sc_S.close() sc_S.close sc_S sc_T.close() sc_T.close sc_T String[] args args private static int binarySearch(int n,int S[], int q, int T[]){
	int FOUND_COUNT = 0;
	
	for(int j=0;j<T.length;j++){
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	}
	return FOUND_COUNT;
    } binarySearch {
	int FOUND_COUNT = 0;
	
	for(int j=0;j<T.length;j++){
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	}
	return FOUND_COUNT;
    } int FOUND_COUNT = 0; FOUND_COUNT 0 for(int j=0;j<T.length;j++){
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	} int j=0; int j=0; j 0 j<T.length j T.length T T.length j++ j++ j {
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	} {
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	} int left = 0; left 0 int right = n; right n int key = T[j]; key T[j] T j while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    } left<right left right {
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    } int mid = (left + right)/2; mid (left + right)/2 (left + right) left right 2 if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1; S[mid] == key S[mid] S mid key {
		    FOUND_COUNT++;
		    break;
		} FOUND_COUNT++ FOUND_COUNT break; if(key < S[mid]) right = mid;
		else left = mid + 1; key < S[mid] key S[mid] S mid right = mid right mid left = mid + 1 left mid + 1 mid 1 return FOUND_COUNT; FOUND_COUNT int n n int S[] S int q q int T[] T
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int[] S;
	int[] T;
	int i = 0;
	int j = 0;
	int FOUND = 0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_S = br.readLine();//data_and_key
	String str_q = br.readLine();
	String str_T = br.readLine();//key_stack

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);
	S = new int[n+1];//S[n] = key
	T = new int[q];

	Scanner sc_S = new Scanner(str_S).useDelimiter("\\s* \\s*");
	Scanner sc_T = new Scanner(str_T).useDelimiter("\\s* \\s*");

	while(sc_S.hasNext()){
	    S[i] = sc_S.nextInt();
	    i++;
	}

	while(sc_T.hasNext()){
	    T[j] = sc_T.nextInt();
	    j++;
	}

	FOUND = binarySearch(n,S,q,T);

	System.out.println(FOUND);

	sc_S.close();
	sc_T.close();
	
    }

    private static int binarySearch(int n,int S[], int q, int T[]){
	int FOUND_COUNT = 0;
	
	for(int j=0;j<T.length;j++){
	    int left = 0;
	    int right = n;
	    int key = T[j];
	    
	    while(left<right){
		int mid = (left + right)/2;
		if(S[mid] == key){
		    FOUND_COUNT++;
		    break;
		}
		else if(key < S[mid]) right = mid;
		else left = mid + 1;
	    }
	}
	return FOUND_COUNT;
    }
}

