#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long INFll = 1000000000000000000ll;
const int MOD = 1000000007;
const int SHIFT = 100000;
int n, m, k;
int a[100500], b[100500];
int f[150][SHIFT * 3];
int main() {
  ios_base::sync_with_stdio(0);
  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] = a[i] - b[i] * k;
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = -SHIFT; j <= SHIFT; ++j) {
      f[i][j + SHIFT] = -1;
    }
  }
  f[0][SHIFT] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = -SHIFT; j <= SHIFT; ++j) {
      f[i + 1][j + SHIFT] = f[i][j + SHIFT];
    }
    for (int j = -SHIFT; j <= SHIFT; ++j) {
      if ((f[i][j + SHIFT] >= 0)) {
        f[i + 1][j + b[i] + SHIFT] =
            max(f[i + 1][j + b[i] + SHIFT], f[i][j + SHIFT] + a[i]);
      }
    }
  }
  if (f[n][SHIFT] == 0)
    cout << -1 << endl;
  else
    cout << f[n][SHIFT] << endl;
  return 0;
}
