#include <bits/stdc++.h>
template <class T>
T _diff(T a, T b) {
  return (a < b ? b - a : a - b);
}
template <class T>
T _abs(T a) {
  return (a < 0 ? -a : a);
}
template <class T>
T _max(T a, T b) {
  return (a > b ? a : b);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
T max3(T a, T b, T c) {
  return (_max(a, b) > c ? _max(a, b) : c);
}
template <class T>
T min3(T a, T b, T c) {
  return (_min(a, b) < c ? _min(a, b) : c);
}
template <class T>
T GCD(T a, T b) {
  a = _abs(a);
  b = _abs(b);
  T tmp;
  while (a % b) {
    tmp = a % b;
    a = b;
    b = tmp;
  }
  return b;
}
template <class T>
T LCM(T a, T b) {
  a = _abs(a);
  b = _abs(b);
  return (a / GCD(a, b)) * b;
}
template <class T>
T toRad(T deg) {
  return (deg * 2.0 * acos(0.0)) / (180.0);
}
template <class T>
T toDeg(T rad) {
  return (rad * 180.0) / (2.0 * acos(0.0));
}
using namespace std;
int dp[105][100005][3], n, a[105], b[105], k;
int func(int p, int s, int sg) {
  int &ret = dp[p][s][sg];
  if (p == n) {
    if (s == 0)
      return 0;
    else
      return -2000000000;
  }
  if (ret != -1) return ret;
  int tmp = a[p] - (k * b[p]), sgt;
  if (sg)
    tmp = tmp - s;
  else
    tmp = tmp + s;
  if (tmp < 0)
    sgt = 1;
  else
    sgt = 0;
  return ret = max(func(p + 1, s, sg), a[p] + func(p + 1, abs(tmp), sgt));
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  int res = func(0, 0, 0);
  if (res == 0) res = -1;
  printf("%d", res);
  puts("");
  return 0;
}
