#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
int N, K;
int A[100001], B[100001];
int dpdp[2][200001];
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N >> K;
  for (i = 0; i < N; i++) cin >> A[i];
  for (i = 0; i < N; i++) cin >> B[i];
  _fill_int((int*)dpdp, -1, sizeof(dpdp) / 4);
  dpdp[0][10000] = 0;
  dpdp[1][10000] = 0;
  for (i = 0; i < N; i++) {
    for (x = 0; x < 20001; x++)
      if (dpdp[0][x] >= 0)
        dpdp[1][x + A[i] - K * B[i]] =
            max(dpdp[1][x + A[i] - K * B[i]], dpdp[0][x] + A[i]);
    memmove(dpdp[0], dpdp[1], sizeof(dpdp) / 2);
  }
  (void)printf("%d\n", dpdp[0][10000] ? dpdp[0][10000] : -1);
}
int main(int argc, char** argv) {
  string s;
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
