#include <bits/stdc++.h>
using namespace std;
int a[111], b[111];
int c[111];
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    int t1, t2, sum1, sum2, flag;
    t1 = t2 = flag = sum1 = sum2 = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
      c[i] = a[i] - k * b[i];
      if (c[i] == 0) {
        flag++;
        ans += a[i];
      } else if (c[i] < 0) {
        t1++;
        sum1 += c[i];
      } else {
        t2++;
        sum2 += c[i];
      }
    }
    if (flag == 0 && (t1 == 0 || t2 == 0))
      printf("-1\n");
    else {
      sum1 = -sum1;
      int f1[111111], f2[111111];
      memset(f1, -1, sizeof(f1));
      memset(f2, -1, sizeof(f2));
      f1[0] = 0;
      f2[0] = 0;
      for (int i = 1; i <= n; i++) {
        if (c[i] < 0) {
          c[i] = -c[i];
          for (int j = sum1; j >= 1; j--)
            if (j >= c[i] && f1[j - c[i]] >= 0 && f1[j - c[i]] + a[i] >= f1[j])
              f1[j] = f1[j - c[i]] + a[i];
        } else if (c[i] > 0) {
          for (int j = sum2; j >= 1; j--)
            if (j >= c[i] && f2[j - c[i]] >= 0 && f2[j - c[i]] + a[i] >= f2[j])
              f2[j] = f2[j - c[i]] + a[i];
        }
      }
      int be = 1;
      int max = 0;
      while (be <= sum1 && be <= sum2) {
        if (f1[be] > 0 && f2[be] > 0 && f1[be] + f2[be] > max) {
          max = f1[be] + f2[be];
        }
        be++;
      }
      if (ans + max)
        printf("%d\n", ans + max);
      else
        printf("-1\n");
    }
  }
  return 0;
}
