#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return b / gcd(a, b) * a; }
int n, m, a[100], b[100], k;
int dp[100][200001];
bool vis[100][200001];
int oo = 1 << 25;
int add = 1e5;
int calc(int i, int sum) {
  if (i == n) return sum ? -oo : 0;
  if (vis[i][sum + add]) return dp[i][sum + add];
  vis[i][sum + add] = 1;
  return dp[i][sum + add] =
             max(calc(i + 1, sum - b[i] * k), calc(i + 1, sum - a[i]) + a[i]);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", b + i);
    sum += b[i];
  }
  sum *= k;
  int res = calc(0, sum) > 0 ? calc(0, sum) : -1;
  printf("%d\n", res);
}
