#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[160], b[160];
int dp[22110];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (cin >> n >> k) {
    memset(dp, -1, sizeof(dp));
    dp[10000] = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
      int x;
      cin >> x;
      b[i] = a[i] - x * k;
    }
    for (int i = 1; i <= n; i++) {
      if (b[i] >= 0) {
        for (int j = 20000; j >= b[i]; j--) {
          if (dp[j - b[i]] != -1) dp[j] = max(dp[j], dp[j - b[i]] + a[i]);
        }
      } else {
        for (int j = 0; j <= 21105; j++) {
          if (dp[j - b[i]] != -1) dp[j] = max(dp[j], dp[j - b[i]] + a[i]);
        }
      }
    }
    if (dp[10000])
      cout << dp[10000] << endl;
    else
      puts("-1");
  }
}
