#include <bits/stdc++.h>
using namespace std;
const int N = 5e4;
const int X[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int Y[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;
int dp[111][N];
int a[111], b[111];
pair<int, int> c[111];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  ;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    c[i] = {a[i] - b[i] * k, a[i]};
  }
  sort(c, c + n);
  reverse(c, c + n);
  if (c[0].first < 0) {
    cout << -1;
    return 0;
  }
  dp[0][c[0].first] = c[0].second;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < N; ++j) {
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      if (j - c[i].first >= 0 && j - c[i].first < N &&
          dp[i - 1][j - c[i].first]) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - c[i].first] + c[i].second);
      }
    }
  }
  int res = dp[n - 1][0];
  if (res == 0) res = -1;
  cout << res;
}
