#include <bits/stdc++.h>
const int inf = 0x7fffffff;
using namespace std;
int dp[100005];
int a[105], b[105];
int w[105];
int n, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 100005; i++) dp[i] = -inf;
  dp[10000] = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    w[i] = a[i] - k * b[i];
  }
  for (int i = 0; i < n; i++) {
    if (w[i] >= 0) {
      for (int j = 20000; j >= w[i]; j--)
        dp[j] = max(dp[j], dp[j - w[i]] + a[i]);
    } else {
      for (int j = 0; j <= 20000 - w[i]; j++)
        dp[j] = max(dp[j], dp[j - w[i]] + a[i]);
    }
  }
  if (dp[10000] == 0)
    cout << -1 << endl;
  else
    cout << dp[10000] << endl;
  return 0;
}
