#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
int taste[101], cal[101], dp[105][150000];
int n, k, cnt;
int solve(int i, int s) {
  if (i >= n) {
    if (s == 100000 && cnt) return 0;
    return -OO;
  }
  if (dp[i][s] != -1) return dp[i][s];
  cnt++;
  int ret = taste[i] + solve(i + 1, s + taste[i] - k * cal[i]);
  cnt--;
  ret = max(ret, solve(i + 1, s));
  return dp[i][s] = ret;
}
int main() {
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) scanf("%d", &taste[i]);
  for (int i = 0; i < n; i++) scanf("%d", &cal[i]);
  int ans = solve(0, 100000);
  printf("%d\n", ans < 0 ? -1 : ans);
  return 0;
}
