#include <bits/stdc++.h>
using namespace std;
int n, k, a[105], b[105], temp, dp[105][210000];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  int maxs = 1000 * n;
  memset(dp, -100, sizeof(dp[0][0]) * 105 * 210000);
  dp[0][maxs] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 2 * maxs; j++) {
      temp = (a[i] - (k * b[i]));
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - temp] + a[i]);
    }
  }
  if (dp[n][maxs] == 0) {
    printf("-1\n");
  } else {
    printf("%d\n", dp[n][maxs]);
  }
}
