#include <bits/stdc++.h>
int max(int a, int b) { return a > b ? a : b; }
int dp[110][(100 * 100 * 10) * 2];
bool v[110][(100 * 100 * 10) * 2];
int n, k, a[110], b[110];
int f(int i, int d) {
  if (i < 0) return d == 0 ? 0 : -1000000;
  if (v[i][d + (100 * 100 * 10)]) return dp[i][d + (100 * 100 * 10)];
  v[i][d + (100 * 100 * 10)] = true;
  return dp[i][d + (100 * 100 * 10)] =
             max(f(i - 1, d), f(i - 1, d + a[i] - k * b[i]) + a[i]);
}
int main(void) {
  int i;
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &b[i]);
  i = f(n - 1, 0);
  printf("%d\n", i ? i : -1);
  return 0;
}
