#include <bits/stdc++.h>
using namespace std;
const int NEGINF = 0xC0C0C0C0;
template <class T>
T gcd(T a, T b) {
  T temp;
  while (b) {
    temp = a;
    a = b;
    b = temp % b;
  }
  return a;
}
template <class T>
T power(T n, T r) {
  T ret = 1;
  while (r) {
    if (r & 1) ret = ret * n;
    n = n * n;
    r /= 2;
  }
  return ret;
}
int a[101], b[101], dp[101][200010];
int main() {
  int n, k, t, ans;
  scanf("%d", &(n));
  scanf("%d", &(k));
  {
    for (int(i) = 0; (i) < (n); i++) scanf("%d", &(a[i]));
  };
  {
    for (int(i) = 0; (i) < (n); i++) scanf("%d", &(b[i]));
  };
  memset(dp, NEGINF, sizeof dp);
  dp[0][100000] = 0;
  for (int(i) = 0; (i) < (n); i++) {
    for (int(j) = 0; (j) < (200010); j++) {
      t = j - (a[i] - b[i] * k);
      dp[i + 1][j] = dp[i][j];
      if (t >= 0 && t < 200010)
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][t] + a[i]);
    }
  }
  ans = dp[n][100000];
  if (ans == 0) ans = -1;
  printf("%d", (ans));
  printf("\n");
}
