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