#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const int N = 200000 * 4 + 111;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int n, k;
int a[111];
int b[111];
int dp[20010][101];
void work() {
  int i, j;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    b[i] *= k;
    b[i] = a[i] - b[i];
  }
  int ans = 0;
  memset(dp, -63, sizeof(dp));
  int fk = 10000;
  dp[fk][0] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 20001; j++) dp[j][i] = dp[j][i - 1];
    for (j = 0; j <= 20000; j++) {
      int t = j + b[i];
      if (t < 0 || t > 20000) continue;
      dp[t][i] = max(dp[j][i - 1] + a[i], dp[t][i]);
    }
  }
  int tp = dp[fk][n];
  if (tp > 0)
    cout << tp << endl;
  else
    cout << "-1\n";
}
int main() {
  cin >> n >> k;
  work();
}
