#include <bits/stdc++.h>
using namespace std;
int dp[2][200010];
int n, k;
int a[110], b[110];
void read() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
}
void solve() {
  int oldR = 0;
  int curR = 1;
  memset(dp, -1, sizeof(dp));
  dp[oldR][(0 + (100000))] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = -100000; j <= 100000; ++j) {
      dp[curR][(j + (100000))] = dp[oldR][(j + (100000))];
      int jj = j - (a[i] - k * b[i]);
      if (jj < -100000 || jj > 100000 || dp[oldR][(jj + (100000))] == -1)
        continue;
      dp[curR][(j + (100000))] =
          max(dp[curR][(j + (100000))], dp[oldR][(jj + (100000))] + a[i]);
    }
    swap(oldR, curR);
  }
  int ans = dp[oldR][(0 + (100000))];
  printf("%d", ans == 0 ? -1 : ans);
}
int main() {
  read();
  solve();
  return 0;
}
