#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 23, maxm = 30000;
int n, K, a[maxn], w[maxn], F[maxn][maxm + 10000];
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]), w[i] = a[i] - w[i] * K;
  memset(F, -1, sizeof(F));
  F[0][15000] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= maxm; j++) {
      if (F[i - 1][j] >= 0) F[i][j] = max(F[i][j], F[i - 1][j]);
      if (F[i - 1][j - w[i]] >= 0)
        F[i][j] = max(F[i][j], F[i - 1][j - w[i]] + a[i]);
    }
  }
  printf("%d\n", (F[n][15000] <= 0) ? (-1) : (F[n][15000]));
  return 0;
}
