#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
pair<int, int> mas[105];
int n, k;
int dp[105][200 * 100 * 10 + 5005];
int go(int v, int diff) {
  if (v == n + 1) return diff == 102000 ? 0 : -1e9;
  if (dp[v][diff] != -1) return dp[v][diff];
  int res = go(v + 1, diff);
  res = max(res, go(v + 1, diff + mas[v].first - mas[v].second) + mas[v].first);
  return dp[v][diff] = res;
}
void solve() {
  n = ri(), k = ri();
  for (int i = (int)(1); i <= (int)(n); i++) mas[i].first = ri();
  for (int i = (int)(1); i <= (int)(n); i++) mas[i].second = ri() * k;
  memset(dp, -1, sizeof(dp));
  int res = go(1, 102000);
  if (res <= 0) {
    cout << -1 << endl;
    return;
  }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
