import java.util.*; public class Main { static final int MAX = 100 * 1000 + 1; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] volts = new int[MAX]; volts[0] = 1; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 1000 * i; j >= 0; j--) { volts[j + x] += volts[j]; } } int[] sums = new int[MAX]; for (int i = 1; i < MAX; i++) { sums[i] += sums[i - 1] + volts[i]; } int[] resists = new int[MAX]; resists[0] = 1; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 1000 * i; j >= 0; j--) { resists[j + x] += resists[j]; } } int a = sc.nextInt(); int b = sc.nextInt(); long ans = 0; for (int i = 1; i * a < MAX; i++) { ans += (sums[Math.min(MAX - 1, i * b)] - sums[i * a - 1]) * (long)resists[i]; } System.out.println(ans); } }