#include <bits/stdc++.h>
using namespace std;
int a[102];
int b[102];
int w[102];
int dp[102][20010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int sum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) w[i] = a[i] - k * b[i];
  int N = 10000;
  int INF = 10000000;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= 2 * N; j++) {
      dp[i][j] = -INF;
    }
  }
  dp[0][N] = 0;
  for (int i = 1; i <= n; i++) {
    if (w[i] >= 0) {
      for (int j = w[i]; j <= 2 * N; j++) {
        dp[i][j] = dp[i - 1][j];
        dp[i][j] = max(dp[i][j], a[i] + dp[i - 1][j - w[i]]);
      }
    } else {
      for (int j = 0; j <= 2 * N + w[i]; j++) {
        dp[i][j] = dp[i - 1][j];
        dp[i][j] = max(dp[i][j], a[i] + dp[i - 1][j - w[i]]);
      }
    }
  }
  cout << (dp[n][N] != 0 ? dp[n][N] : -1);
  return 0;
}
