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