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 in range(N): ndp=[INF]*100001 for j in range(-50000,50001): if dp[j]==INF: continue ndp[j+A[i]-X]=min(ndp[j+A[i]-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)