#include <bits/stdc++.h>
using namespace std;
long long a[110], b[110];
long long n, K;
long long dp[110][100100];
long long F(long long pos, long long sum) {
  if (pos > n) {
    if (sum == 0)
      return 0;
    else
      return -1e18;
  }
  long long &ret = dp[pos][sum];
  if (ret != -1) return ret;
  ret = max(a[pos] + F(pos + 1, sum + a[pos] - K * b[pos]), F(pos + 1, sum));
  return ret;
}
int main() {
  scanf("%lld", &n);
  scanf("%lld", &K);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= n; i++) scanf("%lld", &b[i]);
  memset(dp, -1, sizeof dp);
  long long ans = F(1, 0);
  if (ans <= 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
