import numpy as np N, X = map(int, input().split()) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) if all(a < X for a in A): print(-1) exit() score_sum = 0 bad_subject = [] for a, b in zip(A, B): if a < X: bad_subject.append((X - a, b)) else: score_sum += a - X L = score_sum + 1 dp = np.zeros(L, dtype=int) for a, b in bad_subject: new_dp = dp + b new_dp[a:] = np.minimum(new_dp[a:], dp[:L - a]) dp = new_dp print(dp.min())