#include <bits/stdc++.h>
using namespace std;
int dp[105][300000], n, m, k, v[105], cost;
int main() {
  scanf("%d%d", &n, &k);
  m = n * 100;
  memset(dp, 192, sizeof(dp));
  dp[0][m] = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &cost);
    cost = v[i] - k * cost;
    for (int j = 2 * m; j >= 0; j--)
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - cost] + v[i]);
  }
  printf("%d\n", dp[n][m] ? dp[n][m] : -1);
  return 0;
}
