#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const int mx = 100000;
int n, k;
int a[maxn], b[maxn];
int dp[maxn][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]);
  }
  memset(dp, -0x3f3f3f, sizeof(dp));
  dp[0][mx] = 0;
  for (int i = 1; i <= n; i++) {
    int c = a[i] - k * b[i];
    for (int j = mx * 2; j >= 0; j--) {
      if (j - c < 0 || j - c > mx * 2) continue;
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - c] + a[i]);
    }
  }
  if (dp[n][mx] == 0)
    puts("-1");
  else
    printf("%d\n", dp[n][mx]);
  return 0;
}
