#include <bits/stdc++.h>
using namespace std;
int nn;
int n, k, a[110], b[110], rem[110], con[110], dp[110][20010], ans;
int main() {
  ans = -1;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) b[i] *= k;
  for (int i = 1; i <= n; i++) rem[i] = a[i] - b[i];
  for (int i = 0; i < 110; i++)
    for (int j = 0; j <= 20000; j++) dp[i][j] = -1000000000;
  dp[0][10000] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 20000; j++) {
      if (j - rem[i] >= 0 && j - rem[i] <= 20000)
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - rem[i]] + a[i]);
    }
  }
  if (dp[n][10000] == 0)
    cout << "-1" << endl;
  else
    cout << dp[n][10000] << endl;
  return 0;
}
