#include <bits/stdc++.h>
using namespace std;
const int N = 104, shift = 2500;
int dp[N][444444];
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < 2 * shift; j++) dp[i][j] = -1e9;
  }
  dp[0][shift] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = -1000; j < 1000; j++) {
      dp[i][j + shift] = max(dp[i][j + shift], dp[i - 1][j + shift]);
      int v = a[i] - k * b[i];
      dp[i][j + v + shift] =
          max(dp[i][j + v + shift], dp[i - 1][j + shift] + a[i]);
    }
  }
  cout << (dp[n][shift] == 0 ? -1 : dp[n][shift]) << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  for (int tt = 1; tt <= t; tt++) {
    solve();
  }
}
