import java.util.*;

public class Main{
    int n;
    long[] a;

    Main(){
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    }

    boolean func(long v){
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    }

    public static void main(String[] args){
	new Main();
    }
} import java.util.*; util.* java public class Main{
    int n;
    long[] a;

    Main(){
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    }

    boolean func(long v){
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    }

    public static void main(String[] args){
	new Main();
    }
} Main int n; n long[] a; a Main(){
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    } Main {
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int cnt cnt q; q while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	} sc.hasNext() sc.hasNext sc {
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	} cnt = 0 cnt 0 n = sc.nextInt() n sc.nextInt() sc.nextInt sc if(n == 0) break; n == 0 n 0 break; a = new long[n] a new long[n] n for(int i = 0; i < n; ++i) a[i] = sc.nextLong(); int i = 0; int i = 0; i 0 i < n i n ++i ++i i a[i] = sc.nextLong(); a[i] = sc.nextLong() a[i] a i sc.nextLong() sc.nextLong sc Arrays.sort(a) Arrays.sort Arrays a q = sc.nextInt() q sc.nextInt() sc.nextInt sc for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt; int i = 0; int i = 0; i 0 i < q i q ++i ++i i if(func(sc.nextLong())) ++cnt; if(func(sc.nextLong())) ++cnt; func(sc.nextLong()) func sc.nextLong() sc.nextLong sc ++cnt cnt System.out.printf("%d\n", cnt) System.out.printf System.out System System.out "%d\n" cnt boolean func(long v){
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    } func {
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    } int p = 0 p 0 q = n-1 q n-1 n 1 m; m while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	} p <= q p q {
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	} m = (p+q)/2 m (p+q)/2 (p+q) p q 2 if(a[m] == v) return true; a[m] == v a[m] a m v return true; true if(a[m] > v) q = m-1;
	    else p = m+1; a[m] > v a[m] a m v q = m-1 q m-1 m 1 p = m+1 p m+1 m 1 return false; false long v v public static void main(String[] args){
	new Main();
    } main {
	new Main();
    } new Main() String[] args args public class Main{
    int n;
    long[] a;

    Main(){
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    }

    boolean func(long v){
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    }

    public static void main(String[] args){
	new Main();
    }
} public class Main{
    int n;
    long[] a;

    Main(){
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    }

    boolean func(long v){
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    }

    public static void main(String[] args){
	new Main();
    }
} Main
import java.util.*;

public class Main{
    int n;
    long[] a;

    Main(){
	Scanner sc = new Scanner(System.in);
	int cnt, q;

	while(sc.hasNext()){
	    cnt = 0;
	    n = sc.nextInt();
	    if(n == 0) break;
	    a = new long[n];

	    for(int i = 0; i < n; ++i) a[i] = sc.nextLong();
	    Arrays.sort(a);

	    q = sc.nextInt();
	    for(int i = 0; i < q; ++i) if(func(sc.nextLong())) ++cnt;
	    System.out.printf("%d\n", cnt);
	}
    }

    boolean func(long v){
	int p = 0, q = n-1, m;

	while(p <= q){
	    m = (p+q)/2;
	    if(a[m] == v) return true;
	    if(a[m] > v) q = m-1;
	    else p = m+1;
	}

	return false;
    }

    public static void main(String[] args){
	new Main();
    }
}