#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MAXN = 200;
int a[MAXN];
int b[MAXN];
int memo[100][100020][2];
int n, k;
int solve(int index, int sma, int smb) {
  if (index == n) {
    if (sma == smb) {
      return 0;
    } else {
      return -inf;
    }
  }
  int& ret = memo[index][abs(sma - smb)][sma <= smb];
  if (ret != -1) return ret;
  ret = -inf;
  ret = max(ret, solve(index + 1, sma + a[index], smb + b[index]) + a[index]);
  ret = max(ret, solve(index + 1, sma, smb));
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    b[i] *= k;
  }
  memset(memo, -1, sizeof memo);
  int ans = solve(0, 0, 0);
  if (ans < 1) {
    puts("-1");
  } else {
    printf("%d\n", ans);
  }
}
