#include <bits/stdc++.h>
using namespace std;
int f[102][102 * 102 * 2];
int n, k, a[102], b[102], suma, sumb;
int main() {
  scanf("%d%d", &n, &k);
  suma = sumb = 0;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < (n); i++) {
    scanf("%d", &b[i]);
  }
  memset(f, -1, sizeof(f));
  f[0][0 + 10000] = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = max(-10000, -k * sumb); j <= suma; j++)
      if (f[i][j + 10000] != -1) {
        if (f[i + 1][j + 10000] < f[i][j + 10000]) {
          f[i + 1][j + 10000] = f[i][j + 10000];
        }
        int tmp = j + a[i] - k * b[i];
        if (0 <= tmp + 10000 && tmp + 10000 < 2 * 10000) {
          if (f[i + 1][tmp + 10000] < f[i][j + 10000] + a[i]) {
            f[i + 1][tmp + 10000] = f[i][j + 10000] + a[i];
          }
        }
      }
    suma += a[i];
    sumb += b[i];
  }
  printf("%d\n", f[n][0 + 10000] == 0 ? -1 : f[n][10000]);
  return 0;
}
