#include <bits/stdc++.h>
using namespace std;
int N, K;
int a[100], b[100];
int memory[100][2 * 100000];
int dp(int item, int diff) {
  if (item == N) {
    if (diff == 0) {
      return 0;
    } else {
      return -100000;
    }
  }
  if (memory[item][diff + 100000] == 0) {
    int x = dp(item + 1, diff + a[item] - b[item] * K) + a[item];
    int y = dp(item + 1, diff);
    memory[item][diff + 100000] = max(x, y);
  }
  return memory[item][diff + 100000];
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];
  int ans = dp(0, 0);
  if (ans != 0) {
    cout << ans;
  } else {
    cout << -1;
  }
  return 0;
}
