#include <bits/stdc++.h>
using namespace std;
const int man = 1e2 + 10;
int dp[man][100005], val[man], wi[man];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = n * 100;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &wi[i]);
  }
  memset(dp, -0x3f, sizeof(dp));
  dp[0][ans] = 0;
  for (int i = 1; i <= n; i++) {
    int cc = val[i] - wi[i] * k;
    for (int j = 2 * ans; j >= 0; j--) {
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - cc] + val[i]);
    }
  }
  printf("%d\n", dp[n][ans] ? dp[n][ans] : -1);
  return 0;
}
