#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5;
int solve(int n, int k, int a[], int b[]) {
  int ans = 0, dk[n], p[mx + 1], np[mx + 1];
  for (int i = 0; i < n; i++) dk[i] = a[i] - k * (b[i]);
  for (int i = 1; i <= mx; i++) {
    p[i] = -mx;
    np[i] = -mx;
  }
  p[0] = 0;
  np[0] = 0;
  for (int i = 0; i < n; i++) {
    if (dk[i] >= 0) {
      for (int j = mx; j >= dk[i]; j--) p[j] = max(p[j], p[j - dk[i]] + a[i]);
    } else {
      dk[i] *= -1;
      for (int j = mx; j >= dk[i]; j--)
        np[j] = max(np[j], np[j - dk[i]] + a[i]);
    }
  }
  for (int i = 0; i <= mx; i++) ans = max(ans, p[i] + np[i]);
  if (ans == 0) ans = -1;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  cout << solve(n, k, a, b);
}
