from collections import defaultdict inf = 10 ** 9 N, X = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) if all(a < X for a in A): print(-1) exit() score = 0 cost = 0 dp = defaultdict(int) dp[0] = 0 for a, b in zip(A, B): if a >= X: score += a - X cost += b else: p = X - a ndp = defaultdict(int) for k, v in dp.items(): ndp[k] = max(ndp[k], v) ndp[k+p] = max(ndp[k+p], v + b) dp = ndp tmp = cost for k, v in dp.items(): if k > score: continue tmp = max(tmp, cost + v) print(sum(B) - tmp)