#include <bits/stdc++.h>
using namespace std;
int n, k;
int taste[1001];
int weight[1001], bal[1001];
int maxi = 0;
int dp[109][200009];
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &taste[i]);
    sum += taste[i];
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &weight[i]);
    bal[i] = taste[i] - k * weight[i];
  }
  memset(dp, -1, sizeof dp);
  int t, w;
  dp[0][0 + 10000] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = -1 * 10000; j <= sum; j++) {
      if (dp[i][j + 10000] >= 0) dp[i + 1][j + 10000] = dp[i][j + 10000];
      if (dp[i][(j - bal[i + 1 - 1]) + 10000] >= 0) {
        dp[i + 1][j + 10000] =
            max(dp[i + 1][j + 10000],
                dp[i][(j - bal[i + 1 - 1]) + 10000] + taste[i + 1 - 1]);
      }
    }
  }
  if (dp[n][10000] != 0)
    cout << dp[n][10000] << endl;
  else
    cout << -1 << endl;
}
