#include <bits/stdc++.h>
using namespace std;
int setbit(int n, int i, int v) {
  return ((v) ? (n | (1 << i)) : (n & ~(1 << i)));
}
long long gcd(int i, int j) {
  if (j == 0) return i;
  return gcd(j, i % j);
}
bool chk(int n, int i) {
  if ((n >> i) & 1 == 1) return 1;
  return 0;
}
bool T(pair<pair<int, int>, int> p1, pair<pair<int, int>, int> p2) {
  return (p2.second > p1.second);
}
int n, k;
long long mem[104][30005];
pair<long long, long long> a[105];
long long dp(int i, int s) {
  if (s < -1e4) return -1e4;
  if (i >= n) {
    if (s == 0) return 0;
    return -1e6;
  }
  int tmp = s + 1e5;
  long long& ret = mem[i][tmp];
  if (ret != -1) return ret;
  ret = -1e6;
  ret = dp(i + 1, s + (a[i].first - a[i].second * k)) + a[i].first;
  ret = max(ret, dp(i + 1, s));
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  while (cin >> n) {
    cin >> k;
    for (int i = 0; i < n; i++) cin >> a[i].first;
    for (int i = 0; i < n; i++) cin >> a[i].second;
    memset(mem, -1, sizeof mem);
    int ans = dp(0, 0);
    if (ans <= 0)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
