#include <bits/stdc++.h>
using namespace std;
long x, n, k, a[101], f[101][20001], mn;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  mn = 100 * n;
  memset(f, 192, sizeof(f)), f[0][mn] = 0;
  for (int i = 1, x; i <= n; i++) {
    cin >> x, x = a[i] - x * k;
    for (long j = 2 * mn; j >= 0; j--)
      f[i][j] = max(f[i - 1][j], f[i - 1][j - x] + a[i]);
  }
  if (f[n][mn]) {
    cout << f[n][mn];
    return 0;
  }
  cout << -1;
  return 0;
}
