#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int n, k;
int a[105], b[105];
int dp[105][200015];
void ck(int &x, int y) {
  if (x == -1 || x < y) x = y;
}
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]);
  memset(dp, -1, sizeof(dp));
  dp[0][100000] = 0;
  for (int i = (1); i <= (n); ++i) {
    for (int j = (0); j <= (200002); ++j) {
      if (dp[i - 1][j] == -1) continue;
      ck(dp[i][j], dp[i - 1][j]);
      ck(dp[i][j + a[i] - k * b[i]], dp[i - 1][j] + a[i]);
    }
  }
  if (dp[n][100000] != 0)
    printf("%d\n", dp[n][100000]);
  else
    printf("-1\n");
  return 0;
}
