#include <bits/stdc++.h>
using namespace std;
const int NMAX = 110, BMAX = 180010, Delay = 90000;
int N, K, A[NMAX], B[NMAX], Best[NMAX][BMAX];
int main() {
  scanf("%i %i", &N, &K);
  for (int i = 1; i <= N; ++i) scanf("%i", &A[i]);
  for (int i = 1; i <= N; ++i) scanf("%i", &B[i]), B[i] *= K;
  for (int i = 0; i < NMAX; ++i)
    for (int j = 0; j < BMAX; ++j) Best[i][j] = -(1 << 30);
  Best[0][Delay] = 0;
  for (int i = 0; i < N; ++i)
    for (int j = -90000; j <= 90000; ++j)
      if (Best[i][j + Delay] != -(1 << 30)) {
        Best[i + 1][j + Delay] =
            max(Best[i + 1][j + Delay], Best[i][j + Delay]);
        if (-90000 <= j + A[i + 1] - B[i + 1] &&
            j + A[i + 1] - B[i + 1] <= 90000)
          Best[i + 1][j + A[i + 1] - B[i + 1] + Delay] =
              max(Best[i + 1][j + A[i + 1] - B[i + 1] + Delay],
                  Best[i][j + Delay] + A[i + 1]);
      }
  if (Best[N][Delay] == 0)
    printf("-1");
  else
    printf("%i\n", Best[N][Delay]);
}
