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