#include <bits/stdc++.h>
int dp[30010], a[111], b[111], d[111];
int max(int x, int y) { return x > y ? x : y; }
int main() {
  int n, m, i, j, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    int sum = 0;
    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++) {
      d[i] = a[i] - k * b[i];
    }
    for (i = 0; i <= 30000; i++) dp[i] = -10000000;
    dp[10000] = 0;
    for (i = 1; i <= n; i++) {
      if (d[i] >= 0)
        for (j = 30000; j >= d[i]; j--) {
          if (dp[j - d[i]] != -10000000) {
            dp[j] = max(dp[j - d[i]] + a[i], dp[j]);
          }
        }
      else if (d[i] < 0) {
        for (j = 0; j <= 30000 + d[i]; j++) {
          if (dp[j - d[i]] != -10000000) {
            dp[j] = max(dp[j - d[i]] + a[i], dp[j]);
          }
        }
      }
    }
    if (dp[10000])
      printf("%d\n", dp[10000]);
    else
      printf("-1\n");
  }
}
