#include <bits/stdc++.h>
using namespace std;
int f[2][444444];
int n, k, a[101], b[101];
const int shift = 200000;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int j = 0; j < n; ++j) cin >> b[j];
  memset(f, -1, sizeof(f));
  f[0][0 + shift] = 0;
  int cur = 0, nxt = 1;
  for (int i = 0; i < n; ++i) {
    memset(f[nxt], -1, sizeof(f[nxt]));
    for (int sum = -shift; sum <= shift; ++sum)
      if (f[cur][sum + shift] >= 0) {
        f[nxt][sum + shift] = max(f[nxt][sum + shift], f[cur][sum + shift]);
        f[nxt][sum + a[i] - k * b[i] + shift] = max(
            f[nxt][sum + a[i] - k * b[i] + shift], f[cur][sum + shift] + a[i]);
      }
    swap(cur, nxt);
  }
  if (f[cur][0 + shift] == 0)
    cout << "-1\n";
  else
    cout << f[cur][0 + shift] << endl;
}
