#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
template <typename N>
N gcd(N a, N b) {
  return b ? gcd(b, a % b) : a;
}
void precision(long long pr) {
  cout.precision(pr);
  cout << fixed;
}
const int N = 101;
long long low = -100000021;
long long a[N], b[N], n, k;
long long dp[101][200021];
long long f(long long i, long long x) {
  if (i == n) {
    if (x == 0) return 0;
    return low;
  }
  long long &ret = dp[i][x + 100010];
  if (ret != -1) return ret;
  ret = (f(i + 1, x) > a[i] + f(i + 1, x + a[i] - k * b[i])
             ? f(i + 1, x)
             : a[i] + f(i + 1, x + a[i] - k * b[i]));
  return ret;
}
int main() {
  long long i, j;
  for ((i) = (int)(0); (i) <= (int)(100); (i)++)
    for ((j) = (int)(0); (j) <= (int)(200020); (j)++) dp[i][j] = -1;
  cin >> n >> k;
  for ((i) = (int)(0); (i) <= (int)(n - 1); (i)++) cin >> a[i];
  for ((i) = (int)(0); (i) <= (int)(n - 1); (i)++) cin >> b[i];
  long long ans = f(0, 0);
  if (ans <= 0)
    cout << "-1\n";
  else
    cout << ans << '\n';
  return 0;
}
