#include <bits/stdc++.h>
using namespace std;
int d[200001][101], a[100], b[100], n, s;
int f(int gap, int k) {
  if (k == n) return gap == 100000 ? 0 : -(1 << 29);
  if (d[gap][k] != 2011147154) return d[gap][k];
  int ret = f(gap, k + 1);
  if (gap == 100000) ret = max(ret, 0);
  ret = max(ret, f(gap + (a[k] - s * b[k]), k + 1) + a[k]);
  return d[gap][k] = ret;
}
int main() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  for (int i = 0; i <= 200000; i++) {
    for (int j = 0; j <= n; j++) d[i][j] = 2011147154;
  }
  int res = f(100000, 0);
  if (!res)
    puts("-1");
  else
    printf("%d\n", res);
  return 0;
}
