#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  int m = 20001;
  vector<vector<int> > dp(n + 1, vector<int>(m, -1));
  dp[0][m / 2] = 0;
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 0; j < m; ++j) {
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      if (j - a[i - 1] + k * b[i - 1] >= 0 && j - a[i - 1] + k * b[i - 1] < m &&
          dp[i - 1][j - a[i - 1] + k * b[i - 1]] != -1) {
        dp[i][j] =
            max(dp[i][j], dp[i - 1][j - a[i - 1] + k * b[i - 1]] + a[i - 1]);
      }
    }
  }
  cout << (!dp[n][m / 2] ? -1 : dp[n][m / 2]) << endl;
  return 0;
}
