#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[110], b[110];
int num[110];
int dp[110][310000];
int zero;
int main() {
  int cas = 1;
  while (cin >> n >> k) {
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) num[i] = a[i] - k * b[i];
    zero = 10000;
    for (int i = 0; i <= n; i++)
      for (int j = -10000; j <= 10000; j++) dp[i][j + zero] = -10000000;
    dp[0][zero] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = -10000; j <= 10000; j++)
        if (j + zero - num[i] >= 0 && j + zero - num[i] <= 20000)
          dp[i][j + zero] =
              max(dp[i - 1][j + zero], dp[i - 1][j + zero - num[i]] + a[i]);
    }
    if (dp[n][zero] > 0)
      cout << dp[n][zero] << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
