import math._ object Main { def calc(len: Int, xs: List[Int], ys: List[Int]): Int = { if (xs.isEmpty) 0 else if (len > xs.head) 1 + calc(xs.head, ys, xs.tail) else calc(len, xs.tail, ys) } def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val nw = sc.nextInt val ws = Array.fill(nw)(sc.nextInt).sorted.reverse.toList val nb = sc.nextInt val bs = Array.fill(nb)(sc.nextInt).sorted.reverse.toList val len = Integer.MAX_VALUE val ans = max(calc(len, ws, bs), calc(len, bs, ws)) println(ans) } }