N, X = map(int, input().split()) A = list(map(lambda x: X - int(x), input().split())) B = list(map(int, input().split())) n = sum(A) if n <= 0: print(0) exit() dp = [0] + [sum(B)] * n for i in range(N): if A[i] > 0: for j in range(-1, -n - 2, -1): dp[j] = min(dp[j], dp[max(j - A[i], -n-1)] + B[i]) if dp[-1] == sum(B): print(-1)