#include <bits/stdc++.h>
using namespace std;
int f1[100100], f2[100100], a[110], b[110];
int n, k, ans;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= 100000; i++) f1[i] = f2[i] = -1000000000;
  for (int i = 1; i <= n; i++) {
    int c = a[i] - k * b[i];
    if (c >= 0)
      for (int j = 100000; j >= c; j--) f1[j] = max(f1[j], f1[j - c] + a[i]);
    else
      for (int j = 100000; j >= -c; j--) f2[j] = max(f2[j], f2[j + c] + a[i]);
  }
  for (int i = 0; i <= 100000; i++) ans = max(ans, f1[i] + f2[i]);
  if (ans)
    printf("%d", ans);
  else
    printf("-1");
  return 0;
}
