N, X = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C, D = [], [] V = 0 for i in range(N): if A[i] - X < 0: C.append(X - A[i]) D.append(B[i]) V += A[i] - X if V >= 0: print(0) exit() V = -V S = sum(C) inf = 10 ** 18 pre = [inf] * (S + 1) pre[0] = 0 for i in range(len(C)): dp = [inf] * (S + 1) for j in range(S + 1): dp[j] = pre[j] if j - C[i] >= 0: dp[j] = min(dp[j], pre[j - C[i]] + D[i]) dp, pre = pre, dp ans = inf for i in range(V, S + 1): ans = min(ans, pre[i]) print(ans) if ans != sum(B) else print(-1)