#include <bits/stdc++.h>
using namespace std;
const long long int INF = -1e17;
signed main(void) {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    long long int n, x;
    cin >> n >> x;
    vector<vector<long long int>> dp(n + 1, vector<long long int>(2e4, -1));
    vector<long long int> a(n + 1);
    vector<long long int> b(n + 1);
    for (long long int i = 1; i <= n; i++) cin >> a[i];
    for (long long int i = 1; i <= n; i++) cin >> b[i];
    dp[0][1e4] = 0;
    for (long long int i = 1; i <= n; i++) {
      for (long long int bal = 0; bal < 2e4; bal++) {
        dp[i][bal] = max(dp[i][bal], dp[i - 1][bal]);
        if (bal + a[i] - x * b[i] < 2e4 && bal + a[i] - x * b[i] >= 0 &&
            dp[i - 1][bal] != -1) {
          dp[i][bal + a[i] - x * b[i]] =
              max(dp[i][bal + a[i] - x * b[i]], dp[i - 1][bal] + a[i]);
        }
      }
    }
    if (dp[n][1e4] == 0)
      cout << -1 << endl;
    else
      cout << dp[n][1e4] << endl;
  }
}
