#include <bits/stdc++.h>
using namespace std;
int m[105][30000];
int main() {
  int n, k, i, j, a[105], b[105];
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    int temp;
    cin >> temp;
    b[i] = a[i] - temp * k;
  }
  memset(m, -0x7f, sizeof(m));
  m[0][n * 100] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= 2 * n * 100; j++)
      m[i][j] = max(m[i - 1][j], m[i - 1][j - b[i]] + a[i]);
  }
  cout << (m[n][n * 100] == 0 ? -1 : m[n][n * 100]);
  return 0;
}
