#include <bits/stdc++.h>
int n, k;
int a[100];
int b[100];
int dp[100][100000];
int rec(int i, int bal) {
  if (i == n) {
    if (bal == 0) return 0;
    return -10000;
  }
  int ind = bal + 10000;
  if (dp[i][ind] != -1) {
    return dp[i][ind];
  }
  return dp[i][ind] = std::max(rec(i + 1, bal),
                               rec(i + 1, bal + a[i] - k * b[i]) + a[i]);
}
int main(int, char**) {
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    std::cin >> b[i];
  }
  memset(dp, -1, sizeof(dp));
  int r = rec(0, 0);
  if (r <= 0) r = -1;
  std::cout << r << std::endl;
  return 0;
}
