#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int off = 1e5 - 100;
const int B = 1e4 - 100 + off;
int n, k, a[N], b[N];
int dp[N][B];
int f(int n, int r) {
  if (n == 0) return a[0] * (a[0] - k * b[0] == r - off);
  if (dp[n][r] != -1) return dp[n][r];
  int ans = f(n - 1, r);
  if (f(n - 1, r - a[n] + k * b[n]))
    ans = max(ans, a[n] + f(n - 1, r - a[n] + k * b[n]));
  else if (a[n] - k * b[n] == r - off)
    ans = max(ans, a[n] + f(n - 1, r - a[n] + k * b[n]));
  return dp[n][r] = ans;
}
int main() {
  ios::sync_with_stdio(0);
  while (cin >> n >> k) {
    for (int i = 0; i < N; i++)
      for (int j = 0; j < B; j++) dp[i][j] = -1;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int ans = f(n - 1, off);
    cout << (ans ? ans : -1) << "\n\n";
  }
}
