#include <bits/stdc++.h>
using namespace std;
const long long N = 130009;
long long f[N << 2], a[N], n, k, b[N], V[N];
signed main() {
  scanf("%lld%lld", &n, &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]);
  for (long long i = 1; i <= n; i++) V[i] = a[i] - b[i] * k;
  memset(f, 0xcf, sizeof f);
  f[N] = 0;
  for (long long i = 1; i <= n; i++) {
    if (V[i] >= 0)
      for (long long j = 110009; j >= -110009; j--) {
        f[j + N] = max(f[j + N], f[j - V[i] + N] + a[i]);
      }
    else {
      for (long long j = -110009; j <= 110009; j++) {
        f[j + N] = max(f[j + N], f[j - V[i] + N] + a[i]);
      }
    }
  }
  if (f[N] == 0)
    puts("-1");
  else
    printf("%lld", f[N]);
  return 0;
}
