#include <bits/stdc++.h>
using namespace std;
int n, k, a[105], b[105], w[105], dp1[20010], dp2[20010];
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int j = 1; j <= n; j++) scanf("%d", &b[j]);
    for (int i = 0; i <= 20000; i++) dp1[i] = dp2[i] = -1 << 30;
    dp1[0] = 0, dp2[0] = 0;
    for (int i = 1; i <= n; i++) {
      w[i] = a[i] - k * b[i];
      if (w[i] > 0) {
        for (int j = 20000; j >= w[i]; j--) {
          dp1[j] = max(dp1[j - w[i]] + a[i], dp1[j]);
        }
      } else {
        w[i] = -w[i];
        for (int j = 20000; j >= w[i]; j--) {
          dp2[j] = max(dp2[j - w[i]] + a[i], dp2[j]);
        }
      }
    }
    int maxx = -1;
    for (int i = 0; i <= 20000; i++) {
      maxx = max(maxx, dp1[i] + dp2[i]);
    }
    if (maxx == 0)
      printf("-1\n");
    else
      printf("%d\n", maxx);
  }
  return 0;
}
