#include <bits/stdc++.h>
using namespace std;
const int max_dp = 2e5 + 1;
int dp[101][max_dp];
int n, k;
int a[101], b[101];
int solve(int num, int bal) {
  if (dp[num][bal] != -1) {
    return dp[num][bal];
  }
  if (num == 0) {
    if (bal == 1e5) {
      return 0;
    } else {
      return -1e9;
    }
  }
  int x = solve(num - 1, bal);
  int y = a[num - 1] + solve(num - 1, bal + a[num - 1] - k * b[num - 1]);
  dp[num][bal] = max(x, y);
  return dp[num][bal];
}
int main() {
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int ans = solve(n, 1e5);
  if (ans > 0)
    cout << ans << endl;
  else
    cout << "-1\n";
  return 0;
}
