#include <bits/stdc++.h>
using namespace std;
int n, k;
int aa[101], a[101], b[101], dp[101][200011][2];
int calc(int idx, int cur, bool fl) {
  if (idx >= n) {
    if (cur == 100000 && fl)
      return 0;
    else
      return -1e9;
  }
  int &ret = dp[idx][cur][fl];
  if (ret != -1) return ret;
  ret = -1e9;
  ret = max(ret, calc(idx + 1, cur + a[idx], 1) + aa[idx]);
  ret = max(ret, calc(idx + 1, cur, fl));
  return ret;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < (int)(n); ++i) cin >> aa[i];
  for (int i = 0; i < (int)(101); ++i)
    for (int j = 0; j < (int)(200011); ++j)
      for (int k = 0; k < (int)(2); ++k) dp[i][j][k] = -1;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> b[i];
    b[i] *= k;
    a[i] = aa[i] - b[i];
  }
  if (calc(0, 100000, 0) >= 0) {
    cout << calc(0, 100000, 0);
  } else
    cout << -1;
  return 0;
}
