#include <bits/stdc++.h>
using namespace std;
int n, k, a[200], b[200], i, j, DP[3 * 10000];
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i], b[i] *= k;
  for (j = 10000; j >= -10000; j--) DP[j + 10000] = -(10000 * 10000);
  DP[10000] = 0;
  for (i = 1; i <= n; i++)
    if (a[i] - b[i] > 0) {
      for (j = 10000; j >= -10000; j--)
        if (j + 10000 + a[i] - b[i] >= 0 &&
            j + 10000 + a[i] - b[i] <= 2 * 10000)
          DP[j + 10000 + a[i] - b[i]] =
              max(DP[j + 10000] + a[i], DP[j + 10000 + a[i] - b[i]]);
    } else {
      for (j = -10000; j <= 10000; j++)
        if (j + 10000 + a[i] - b[i] >= 0 &&
            j + 10000 + a[i] - b[i] <= 2 * 10000)
          DP[j + 10000 + a[i] - b[i]] =
              max(DP[j + 10000] + a[i], DP[j + 10000 + a[i] - b[i]]);
    }
  if (!DP[10000])
    cout << "-1" << endl;
  else
    cout << DP[10000] << endl;
}
