#include <bits/stdc++.h>
struct E {
  int a;
  int b;
  int c;
} list[110];
const int OFFSET = 10000;
int dp[20010];
int buf[20010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &list[i].a);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &list[i].b);
    list[i].b = list[i].b * k;
    list[i].c = list[i].a - list[i].b;
  }
  memset(dp, -1, sizeof(dp));
  dp[OFFSET] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = -10000; j <= 10000; j++) {
      buf[j + OFFSET] = dp[j + OFFSET];
    }
    for (int j = -10000; j <= 10000; j++) {
      if (dp[j + OFFSET] == -1) continue;
      if (j + list[i].c < -10000) continue;
      if (buf[j + list[i].c + OFFSET] < dp[j + OFFSET] + list[i].a) {
        buf[j + list[i].c + OFFSET] = dp[j + OFFSET] + list[i].a;
      }
    }
    for (int j = -10000; j <= 10000; j++) {
      dp[j + OFFSET] = buf[j + OFFSET];
    }
  }
  if (dp[OFFSET] == 0) {
    puts("-1");
  } else {
    printf("%d\n", dp[OFFSET]);
  }
  return 0;
}
