#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 4;
long long n, k, a[110], b[110], dp[110][N], c = 100002;
long long solve(long long x, long long dif) {
  if (x > n) {
    if (dif == c) return 0;
    return -1e9;
  }
  if (dp[x][dif] != -1) return dp[x][dif];
  long long &ret = dp[x][dif];
  ret = solve(x + 1, dif);
  ret = max(ret, solve(x + 1, dif + b[x]) + a[x]);
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.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] = a[i] - k * b[i];
  }
  memset(dp, -1, sizeof(dp));
  long long ans = solve(1, c);
  if (ans <= 0)
    cout << "-1";
  else
    cout << (long long)ans;
}
