import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();

	public static void main(String[] args) throws Exception {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	}
	public static boolean member( int t, int[] num ) {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	}
	public static void slist(int v) {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	}
	public static BufferedReader getReader(String path) throws Exception{
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	}
	public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.FileInputStream; FileInputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();

	public static void main(String[] args) throws Exception {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	}
	public static boolean member( int t, int[] num ) {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	}
	public static void slist(int v) {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	}
	public static BufferedReader getReader(String path) throws Exception{
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	}
	public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} Main static ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() public static void main(String[] args) throws Exception {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	} main {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	} BufferedReader br; br if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		} args.length > 0 && args[0].equals("File") == true args.length > 0 args.length args args.length 0 args[0].equals("File") == true args[0].equals("File") args[0].equals args[0] args 0 "File" true {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt") br getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt") getReader "C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt" {
			br = getReader();
		} br = getReader() br getReader() getReader int snum = getInt(br); snum getInt(br) getInt br int[] snumAry = getIntAry(br); snumAry getIntAry(br) getIntAry br int tnum = getInt(br); tnum getInt(br) getInt br int[] tnumAry = getIntAry(br); tnumAry getIntAry(br) getIntAry br int count = 0; count 0 for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		} int t = 0; int t = 0; t 0 t < tnumAry.length t tnumAry.length tnumAry tnumAry.length t++ t++ t {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		} {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		} if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			} member(tnumAry[t], snumAry) == true member(tnumAry[t], snumAry) member tnumAry[t] tnumAry t snumAry true {
				slist(tnumAry[t]);
//				break;
			} slist(tnumAry[t]) slist tnumAry[t] tnumAry t count = list.size() count list.size() list.size list System.out.println(count) System.out.println System.out System System.out count String[] args args public static boolean member( int t, int[] num ) {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	} member {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	} int i = 0; i 0 int j = num.length-1; j num.length-1 num.length num num.length 1 int k = i + (j-i)/2 ; k i + (j-i)/2 i (j-i)/2 (j-i) j i 2 while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		} i<=j i j {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		} if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			} t == num[k] t num[k] num k {
				return true;
			} return true; true if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			} t > num[k] t num[k] num k {
				i = k+1;
			} i = k+1 i k+1 k 1 {
				j = k-1;
			} j = k-1 j k-1 k 1 k = i + (j-i)/2 k i + (j-i)/2 i (j-i)/2 (j-i) j i 2 return false; false int t t int[] num num public static void slist(int v) {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	} slist {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	} boolean insert = false; insert false for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		} int i = 0 ; int i = 0 ; i 0 i < list.size() i list.size() list.size list i++ i++ i {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		} {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		} if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			} list.get(i) == v list.get(i) list.get list i v {
				insert = true;
				break;
			} insert = true insert true break; if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			} list.get(i) > v list.get(i) list.get list i v {
				list.add(i,v);
				insert = true;
				break;
			} list.add(i,v) list.add list i v insert = true insert true break; if ( insert == false ) {
			list.add(v);
		} insert == false insert false {
			list.add(v);
		} list.add(v) list.add list v int v v public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	} getReader {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	} return( new BufferedReader(new InputStreamReader(
				System.in))); ( new BufferedReader(new InputStreamReader(
				System.in))) public static BufferedReader getReader(String path) throws Exception{
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	} getReader {
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	} return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path)))); ( new BufferedReader(new InputStreamReader(
				new FileInputStream(path)))) String path path public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	} getInt {
		String line = br.readLine();
		return Integer.valueOf(line);
	} String line = br.readLine(); line br.readLine() br.readLine br return Integer.valueOf(line); Integer.valueOf(line) Integer.valueOf Integer line BufferedReader br br public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	} getAry {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	} String line = br.readLine(); line br.readLine() br.readLine br String[] nstr = line.split(" "); nstr line.split(" ") line.split line " " return nstr; nstr BufferedReader br br public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	} getIntAry {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	} String line = br.readLine(); line br.readLine() br.readLine br String[] nstr = line.split(" "); nstr line.split(" ") line.split line " " int[] n = new int[nstr.length]; n new int[nstr.length] nstr.length nstr nstr.length for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		} int i=0 ; int i=0 ; i 0 i < nstr.length i nstr.length nstr nstr.length i++ i++ i {
			n[i] = Integer.valueOf(nstr[i]);
		} {
			n[i] = Integer.valueOf(nstr[i]);
		} n[i] = Integer.valueOf(nstr[i]) n[i] n i Integer.valueOf(nstr[i]) Integer.valueOf Integer nstr[i] nstr i return n; n BufferedReader br br public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	} getAryMl {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	} int n = getInt(br); n getInt(br) getInt br int[] ary = new int[n]; ary new int[n] n for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		} int i=0 ; int i=0 ; i 0 i < n i n i++ i++ i {
			ary[i] = getInt(br);
		} {
			ary[i] = getInt(br);
		} ary[i] = getInt(br) ary[i] ary i getInt(br) getInt br return ary; ary BufferedReader br br public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	} putAry {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	} for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		} {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		} System.out.print(ary[i]) System.out.print System.out System System.out ary[i] ary i if ( i < num-1) {
				System.out.print(" ");
			} i < num-1 i num-1 num 1 {
				System.out.print(" ");
			} System.out.print(" ") System.out.print System.out System System.out " " System.out.println("") System.out.println System.out System System.out "" int[] ary ary int num num public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	} putAry {
		putAry(ary, ary.length ) ;
	} putAry(ary, ary.length ) putAry ary ary.length ary ary.length int[] ary ary public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	} isPrime {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	} int r = (int)Math.sqrt((double)n)+1; r (int)Math.sqrt((double)n)+1 (int)Math.sqrt((double)n) Math.sqrt Math (double)n 1 for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		} int j = 2 ; int j = 2 ; j 2 j < r j r j += 1 j += 1 j 1 {
			if ( n%j == 0 ) {
				return false;
			}
		} {
			if ( n%j == 0 ) {
				return false;
			}
		} if ( n%j == 0 ) {
				return false;
			} n%j == 0 n%j n j 0 {
				return false;
			} return false; false return true; true int n n public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();

	public static void main(String[] args) throws Exception {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	}
	public static boolean member( int t, int[] num ) {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	}
	public static void slist(int v) {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	}
	public static BufferedReader getReader(String path) throws Exception{
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	}
	public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();

	public static void main(String[] args) throws Exception {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	}
	public static boolean member( int t, int[] num ) {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	}
	public static void slist(int v) {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	}
	public static BufferedReader getReader(String path) throws Exception{
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	}
	public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

} Main
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();

	public static void main(String[] args) throws Exception {
		BufferedReader br;
		if( args.length > 0 && args[0].equals("File") == true ) {
			br = getReader("C:\\Users\\USER\\Downloads\\ALDS1_4_A-in8.txt");
		} else {
			br = getReader();
		}
		int snum = getInt(br);
		int[] snumAry = getIntAry(br);
		int tnum = getInt(br);
		int[] tnumAry = getIntAry(br);
		int count = 0;
		for( int t = 0; t < tnumAry.length ; t++ ) {
			if ( member(tnumAry[t], snumAry) == true ) {
				slist(tnumAry[t]);
//				break;
			}
		}
		count = list.size();
//		System.out.println("");
		System.out.println(count);
	}
	public static boolean member( int t, int[] num ) {
		int i = 0;
		int j = num.length-1;
		int k = i + (j-i)/2 ;
		while(i<=j) {
			if (t == num[k]) {
				return true;
			} else if ( t > num[k]) {
				i = k+1;
			} else {
				j = k-1;
			}
			k = i + (j-i)/2;
		}
		return false;
	}
	public static void slist(int v) {
		boolean insert = false;
		for( int i = 0 ; i < list.size() ; i++ ) {
			if ( list.get(i) == v) {
				insert = true;
				break;
			} else if ( list.get(i) > v ) {
				list.add(i,v);
				insert = true;
				break;
			}
		}
		if ( insert == false ) {
			list.add(v);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(
				System.in)));
	}
	public static BufferedReader getReader(String path) throws Exception{
		return( new BufferedReader(new InputStreamReader(
				new FileInputStream(path))));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	}
	public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

}