#include <bits/stdc++.h>
using namespace std;
int i, n, k, a[200];
map<int, int> c, p;
int main() {
  cin >> n >> k;
  for (; i < 2 * n; i++) {
    cin >> a[i];
    if (i >= n) a[i] = a[i - n] - k * a[i];
  }
  for (c[0] = i = 0; i < n; i++)
    for (auto it = (p = c).begin(); it != p.end(); it++)
      c[it->first + a[i + n]] = max(c[it->first + a[i + n]], a[i] + it->second);
  cout << (c[0] ? c[0] : -1);
}
