#include <bits/stdc++.h>
using namespace std;
struct zz {
  int a;
  int b;
} p[110];
int dp[110][200010];
int main() {
  int n, k, i, j, x;
  while (scanf("%d%d", &n, &k) != EOF) {
    for (i = 1; i <= n; i++) scanf("%d", &p[i].a);
    for (i = 1; i <= n; i++) scanf("%d", &x), p[i].b = x * k;
    memset(dp, -0x3f, sizeof(dp));
    dp[0][10000] = 0;
    for (i = 1; i <= n; i++) {
      int w = p[i].a - p[i].b;
      for (j = 12000; j >= w; j--) {
        if (dp[i - 1][j] < dp[i - 1][j - w] + p[i].a)
          dp[i][j] = dp[i - 1][j - w] + p[i].a;
        else
          dp[i][j] = dp[i - 1][j];
      }
    }
    if (dp[n][10000])
      printf("%d\n", dp[n][10000]);
    else
      printf("-1\n");
  }
  return 0;
}
