import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int Nw = sc.nextInt(); int[] w = new int[Nw]; for(int i = 0; i < Nw; i++) { w[i] = sc.nextInt(); } int Nb = sc.nextInt(); int[] b = new int[Nb]; for(int i = 0; i < Nb; i++) { b[i] = sc.nextInt(); } Arrays.sort(w); Arrays.sort(b); int[] lowW = new int[21]; int[] lowB = new int[21]; lowW[0] = -1; lowW[1] = -1; lowB[0] = -1; lowB[1] = -1; for(int i = 2; i < 21; i++) { boolean flg = true; for(int j = Nw - 1; j >= 0; j--) { if(w[j] < i) { lowW[i] = j; flg = false; break; } } if(flg) lowW[i] = -1; flg = true; for(int j = Nb - 1; j >= 0; j--) { if(b[j] < i) { lowB[i] = j; flg = false; break; } } if(flg) lowB[i] = -1; } // dpw[i]はw[i]を一番下とした時のピラミッドの高さの最大値 // dpb[i]はb[i]を一番下とした時のピラミッドの高さの最大値 int[] dpw = new int[Nw]; int[] dpb = new int[Nb]; dpw[0] = 1; dpb[0] = 1; if(lowB[w[0]] >= 0) dpw[0] = 2; if(lowW[b[0]] >= 0) dpb[0] = 2; int indexw = 1; int indexb = 1; for(int i = 0; i < Nw + Nb - 2; i++) { if(indexw < Nw) { if(lowB[w[indexw]] == -1) { dpw[indexw] = 1; indexw++; } else if(lowB[w[indexw]] < indexb) { dpw[indexw] = 1 + dpb[lowB[w[indexw]]]; indexw++; } } if(indexb < Nb) { if(lowW[b[indexb]] == -1) { dpb[indexb] = 1; indexb++; } else if(lowW[b[indexb]] < indexw) { dpb[indexb] = 1 + dpw[lowW[b[indexb]]]; indexb++; } } } int ans = Math.max(dpw[Nw - 1], dpb[Nb - 1]); System.out.println(ans); } }