#include <bits/stdc++.h>
using namespace std;
int n, m, ans, k;
int a[1005], b[1005];
int w[1005];
int dp[200005];
bool solve() {
  int i, j;
  memset(dp, -0x3f3f3f3f, sizeof(dp));
  dp[10000] = 0;
  for (i = 1; i <= n; i++) {
    if (w[i] >= 0) {
      for (j = 20000; j >= w[i]; j--) {
        if (dp[j - w[i]] != -0x3f3f3f3f)
          dp[j] = max(dp[j], dp[j - w[i]] + a[i]);
      }
    } else {
      for (j = 0; j < 20000; j++) {
        if (dp[j - w[i]] != -0x3f3f3f3f)
          dp[j] = max(dp[j], dp[j - w[i]] + a[i]);
      }
    }
  }
  ans = dp[10000];
  return dp[10000] != 0;
}
int main() {
  int i, j;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (i = 1; i <= n; i++) w[i] = a[i] - k * b[i];
  if (solve())
    printf("%d\n", ans);
  else
    printf("-1\n");
  return 0;
}
