import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int A = sc.nextInt(); int[] cardA = new int[A]; for (int i = 0; i < cardA.length; i++) { cardA[i] = sc.nextInt(); } int C = sc.nextInt(); int[] cardC = new int[C]; for (int i = 0; i < cardC.length; i++) { cardC[i] = sc.nextInt(); } sc.close(); Arrays.sort(cardA); Arrays.sort(cardC); boolean[] usedA = new boolean[A]; int ans = 0; for (int n = 0; n < N; n++) { int curC = n % C; if (n % A == 0) { Arrays.fill(usedA, false); } boolean used = false; for (int i = 0; i < usedA.length; i++) { if (!usedA[i] && cardA[i] > cardC[curC]) { used = true; usedA[i] = true; break; } } if (used) { ans++; continue; } for (int i = 0; i < usedA.length; i++) { if (!usedA[i]) { usedA[i] = true; break; } } } System.out.println(ans); } }