#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
int n, k, maxn;
int a[MAXN], b[MAXN];
int w[MAXN];
int f[1000 * MAXN], g[1000 * MAXN], ans;
int main() {
  scanf("%d%d", &n, &k);
  ans = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    w[i] = a[i] - k * b[i];
  }
  maxn = 1000 * n;
  memset(f, -1, sizeof(f));
  f[0] = 0;
  for (int i = 1; i <= maxn; i++) {
    f[i] = g[i] = -233333333;
  }
  f[0] = g[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = maxn; j >= abs(w[i]); j--) {
      if (w[i] >= 0) {
        f[j] = max(f[j], f[j - w[i]] + a[i]);
      } else
        g[j] = max(g[j], g[j + w[i]] + a[i]);
    }
  }
  for (int i = 0; i <= maxn; i++) {
    ans = max(ans, f[i] + g[i]);
  }
  if (ans)
    cout << ans << endl;
  else
    puts("-1");
  return 0;
}
