#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[110], b[110], v[110], j, ans, po[100100], ne[100100];
int main() {
  cin >> n >> k, m = 100000;
  for (int i = 1; i <= m; po[i] = ne[i] = -1000000000, ++i)
    ;
  for (int i = 1; i <= n; cin >> a[i], ++i)
    ;
  for (int i = 1; i <= n; cin >> b[i], v[i] = a[i] - k * b[i], i++)
    ;
  for (int i = 1; i <= n; i++)
    if (v[i] >= 0)
      for (j = m; j >= v[i]; po[j] = max(po[j], po[j - v[i]] + a[i]), --j)
        ;
    else
      for (v[i] = -v[i], j = m; j >= v[i];
           ne[j] = max(ne[j], ne[j - v[i]] + a[i]), --j)
        ;
  for (int i = 0; i <= m; ans = max(ans, po[i] + ne[i]), ++i)
    ;
  if (ans)
    cout << ans;
  else
    cout << -1;
}
