#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const long long INF = 1e18 + 5;
const long long maxn = 5e5 + 5;
long long n = 100000000000, a[15555], d[5], mx = -1000000001;
long long u[111], b[11005], sum, cnt, r[555];
map<long long, long long> num;
long long bi(long long x, long long y) {
  if (y == 0) return 1ll;
  if (y == 1) return x;
  long long z = bi(x, y / 2);
  z = z * z % n;
  if (y & 1) z = z * x % n;
  return z % n;
}
long long ti, tin[555], fup[555], x[555], y[555], dp[101][300005];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i], b[i] = a[i] - k * b[i];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 300000; j++) dp[i][j] = -1e9;
  int K = 150000;
  dp[0][K] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 300000; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j - b[i] >= 0 && j - b[i] <= 300000)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - b[i]] + a[i]);
    }
  if (dp[n][K] == 0) dp[n][K] = -1;
  cout << dp[n][K];
  return 0;
}
