#include <bits/stdc++.h>
using namespace std;
int A[100], B[100];
int DP[123][200000];
void D(int n, int b) {
  if (DP[n - 1][b + 100000] == -1) return;
  DP[n][b + 100000] = max(DP[n][b + 100000], DP[n - 1][b + 100000]);
  DP[n][b + A[n - 1] - B[n - 1] + 100000] =
      max(DP[n][b + A[n - 1] - B[n - 1] + 100000],
          DP[n - 1][b + 100000] + A[n - 1]);
}
int main() {
  int n, k;
  cin >> n >> k;
  memset(DP, -1, sizeof(DP));
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> B[i];
    B[i] *= k;
  }
  DP[0][100000] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = -100000; j <= 100000; j++) {
      D(i, j);
    }
  }
  if (DP[n][100000] == 0) {
    cout << -1 << endl;
  } else {
    cout << DP[n][100000] << endl;
  }
  return 0;
}
