#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char* s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char* s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
int n, k;
int a[105];
int b[105];
int dp[105][200005];
const int X = 100000;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> k;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n + 1; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n + 1; i++) {
    for (int j = -X; j < X + 1000; j++) {
      dp[i][j + X] = -1;
    }
  }
  dp[0][0 + X] = 0;
  for (int i = 1; i < n + 1; i++) {
    for (int j = -X; j < X; j++) {
      if (dp[i - 1][j + X] != -1) {
        dp[i][j + X] = max(dp[i][j + X], dp[i - 1][j + X]);
      }
      if (j - a[i] + k * b[i] + X >= 0 &&
          dp[i - 1][j - a[i] + k * b[i] + X] != -1) {
        dp[i][j + X] =
            max(dp[i - 1][j + X], dp[i - 1][j - a[i] + k * b[i] + X] + a[i]);
      }
    }
  }
  cout << (dp[n][0 + X] ? dp[n][0 + X] : -1) << '\n';
}
