#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 105;
const int R = 1e5;
int dp[N][3 * R + 4];
int a[N], b[N], c[N];
int n;
int k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    b[i] *= k;
    c[i] = a[i] - b[i];
  }
  memset(dp, -1, sizeof(dp));
  int ans = -100000;
  dp[0][R] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 2 * R; j++) {
      if (j - c[i] >= 0)
        if (dp[i - 1][j - c[i]] != -1)
          dp[i][j] = max(dp[i][j], dp[i - 1][j - c[i]] + a[i]);
      if (dp[i - 1][j] != -1) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
    }
  }
  if (dp[n][R] == 0) dp[n][R] = -1;
  cout << dp[n][R];
  return 0;
}
