#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
const long long Mod = 1e9 + 7;
int a[maxn], b[maxn];
int dp[maxn * 10];
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    memset(dp, -0x3f3f3f3f, sizeof dp);
    dp[maxn] = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
      b[i] = a[i] - b[i] * k;
    }
    for (int i = 1; i <= n; i++) {
      if (b[i] >= 0) {
        for (int j = 10000; j >= -10000; j--) {
          dp[j + maxn] = max(dp[j + maxn], dp[j - b[i] + maxn] + a[i]);
        }
      } else {
        for (int j = -10000; j <= 10000; j++) {
          dp[j + maxn] = max(dp[j + maxn], dp[j - b[i] + maxn] + a[i]);
        }
      }
    }
    cout << (dp[maxn] == 0 ? -1 : dp[maxn]) << endl;
  }
  return 0;
}
