#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[107], b[107];
int dp[107][50007];
int solve(int idx = 0, int def = 1e4) {
  if (idx == n) {
    return def == 1e4 ? 0 : -4e4;
  }
  int &ret = dp[idx][def];
  if (ret + 1) return ret;
  ret = solve(idx + 1, def);
  ret = max(ret, a[idx] + solve(idx + 1, def + a[idx] - k * b[idx]));
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", b + i);
  }
  int ans = solve();
  if (ans <= 0)
    puts("-1");
  else
    cout << ans << endl;
}
