#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[110];
int b[110];
int dp[121000];
int main(int argc, char *argv[]) {
  cin >> n >> k;
  for (int i = 0; i < n; i += 1) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i += 1) {
    cin >> b[i];
  }
  for (int i = 0; i < 121000; i += 1) {
    dp[i] = -1;
  }
  dp[100000] = 0;
  for (int i = 0; i < n; i += 1) {
    int x = a[i] - k * b[i];
    if (x > 0) {
      for (int j = 121000 - 1; j >= x; j -= 1) {
        if (dp[j - x] != -1) {
          if (dp[j] == -1 || dp[j - x] + a[i] > dp[j]) {
            dp[j] = dp[j - x] + a[i];
          }
        }
      }
    } else {
      for (int j = 0; j - x < 121000; j += 1) {
        if (dp[j - x] != -1) {
          if (dp[j] == -1 || dp[j - x] + a[i] > dp[j]) {
            dp[j] = dp[j - x] + a[i];
          }
        }
      }
    }
  }
  if (dp[100000] == 0) {
    dp[100000] = -1;
  }
  cout << dp[100000] << endl;
  return 0;
}
