#include <bits/stdc++.h>
using namespace std;
void Fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
}
inline int D() {
  int t;
  scanf("%d", &t);
  return t;
}
inline long long llD() {
  long long t;
  scanf("%lld", &t);
  return t;
}
long long MOD = 1e9 + 7;
long long OO = 1e9;
const int N = 1e2 + 2, M = 1e5 + 5;
int arr[N];
int pre[N];
int dp[N][M];
long long n, m, k, cnt, SU, idx, len, MN, MX, T;
long long l, r, mid;
long long a, b, c, d;
vector<pair<long long, long long>> vec;
string str, s;
long long MNX, MNY, MXX, MXY, valx, valy;
long long Solve(int idx, int Sum) {
  if (idx == n) return (Sum == 0) ? 0 : -OO;
  int &ret = dp[idx][Sum];
  if (~ret) return ret;
  long long x = Solve(idx + 1, Sum);
  long long y = arr[idx] + Solve(idx + 1, Sum + (arr[idx] - m * pre[idx]));
  return ret = max(x, y);
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 0; i < n; ++i) cin >> pre[i];
  cnt = Solve(0, 0);
  if (cnt < 1) cnt = -1;
  cout << cnt << "\n";
}
