#include <bits/stdc++.h>
using namespace std;
int n, k, f[101][50001], a[101], b[101];
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]);
  for (int i = 0; i <= 100; i++)
    for (int j = 0; j <= 50000; j++) f[i][j] = -99999999;
  f[0][20000] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = -10000; j <= 10000; j++)
      f[i][j + 20000] = max(f[i][j + 20000],
                            max(f[i - 1][j + 20000],
                                f[i - 1][j - a[i] + k * b[i] + 20000] + a[i]));
  int ans = -1;
  if (f[n][20000]) ans = f[n][20000];
  printf("%d", ans);
}
