#include <bits/stdc++.h>
using namespace std;
bool debug = false;
const int abc = 25000;
int dp[105][50005];
int n, k;
int a[105], b[105];
int main(int argc, char* argv[]) {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][abc] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 50000; j++) {
      if (dp[i - 1][j] == -1) continue;
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      dp[i][j + a[i] - k * b[i]] =
          max(dp[i][j + a[i] - k * b[i]], dp[i - 1][j] + a[i]);
    }
  }
  if (dp[n][abc] == 0) {
    cout << -1;
    return 0;
  }
  cout << dp[n][abc];
  return 0;
}
