N,X=map(int,input().split()) A=[int(x) for x in input().split()] B=[int(x) for x in input().split()] INF=10**18 dp=[INF]*100001 dp[0]=0 for i,a in enumerate(A): ndp=[INF]*100001 for j in range(-50000,50001): ndp[j+a-X]=min(ndp[j+a-X],dp[j]) ndp[j]=min(ndp[j],dp[j]+B[i]) dp=ndp ans=min(dp[0:50001]) if ans==sum(B): print(-1) else: print(ans)