#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[111];
int b[111];
pair<int, int> pa[111], pb[111], p[111];
int da[11111], db[11111];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) b[i] *= k;
  for (int i = 0; i < n; ++i) {
    p[i] = make_pair(a[i] - b[i], a[i]);
  }
  int la, lb;
  la = lb = 0;
  int answer = 0;
  for (int i = 0; i < n; ++i) {
    if (p[i].first == 0) {
      answer += p[i].second;
      continue;
    }
    if (p[i].first < 0) {
      pa[la++] = make_pair(-p[i].first, p[i].second);
    } else {
      pb[lb++] = p[i];
    }
  }
  memset(da, 0, sizeof(da));
  memset(db, 0, sizeof(db));
  for (int i = 0; i < la; ++i) {
    for (int j = 10000; j >= 0; --j) {
      if (j == 0 || da[j] != 0) {
        da[j + pa[i].first] = max(da[j + pa[i].first], da[j] + pa[i].second);
      }
    }
  }
  for (int i = 0; i < lb; ++i) {
    for (int j = 10000; j >= 0; --j) {
      if (j == 0 || db[j] != 0) {
        db[j + pb[i].first] = max(db[j + pb[i].first], db[j] + pb[i].second);
      }
    }
  }
  int mx = 0;
  for (int i = 1; i <= 10000; ++i) {
    if (da[i] != 0 && db[i] != 0) {
      if (da[i] + db[i] > mx) {
        mx = da[i] + db[i];
      }
    }
  }
  answer += mx;
  if (answer == 0)
    cout << -1;
  else
    cout << answer;
  return 0;
}
