#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
static constexpr int inf = std::numeric_limits<int>::max() / 4;
const int M = 100;
int A[M], B[M], n, id = 0;
int dp[M][300100];
unordered_map<int, int> mep;
int call(int i, int diff) {
  if (i == n) return diff == 0 ? 0 : -inf;
  if (mep[diff] == 0) mep[diff] = ++id;
  if (dp[i][mep[diff]] != -1) return dp[i][mep[diff]];
  int a = -inf, b = -inf;
  a = A[i] + call(i + 1, diff + A[i] - B[i]);
  b = call(i + 1, diff);
  return dp[i][mep[diff]] = max(a, b);
}
int main() {
  int i, j, k;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  for (i = 0; i < n; i++) scanf("%d", &B[i]), B[i] *= k;
  memset((dp), (-1), sizeof(dp));
  k = call(0, 0);
  k > 0 ? printf("%d\n", k) : printf("%d\n", -1);
  return 0;
}
