#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 * 100 + 10, INF = INT_MAX, MOD = 1e9 + 7,
          MAXW = 4000 * 100 + 1, SHIFT = 2000 * 100;
int a[MAXN], b[MAXN], dp[MAXN][MAXW];
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  memset(dp, -1, sizeof dp);
  dp[0][SHIFT] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < MAXW; j++) {
      if (dp[i - 1][j] == -1) continue;
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      dp[i][j + a[i] - b[i] * k] =
          max(dp[i][j + a[i] - b[i] * k], dp[i - 1][j] + a[i]);
    }
  cout << (dp[n][SHIFT] ? dp[n][SHIFT] : -1) << endl;
  return 0;
}
