#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, k;
  cin >> N >> k;
  int a[101], b[101];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }
  int dp[10001][2];
  for (int i = 0; i < 10001; i++) {
    dp[i][0] = 0;
    dp[i][1] = 0;
  }
  dp[5000][0] = 1;
  dp[5000][1] = 1;
  for (int i = 0; i < N; i++) {
    int x = a[i] - k * b[i];
    for (int j = 0; j < 10001; j++) {
      if (j + x < 10001 && j + x >= 0 && dp[j][0]) {
        dp[j + x][1] = max(dp[j + x][0], dp[j][0] + a[i]);
      }
    }
    for (int j = 0; j < 10001; j++) {
      dp[j][0] = dp[j][1];
    }
    for (int k = 4980; k < 5021; k++) {
    }
  }
  if (dp[5000][0] > 1)
    cout << dp[5000][0] - 1 << endl;
  else
    cout << -1 << endl;
  return 0;
}
