N,H = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) ruisekiwa=[0]*(N+1) for i in range(N): ruisekiwa[i+1]=ruisekiwa[i]+B[i] left=0 right=0 now=0 ans=0 score=0 for i in range(N): if now+B[i]*(i+1-left)<=H: score+=A[i] now+=B[i]*(i+1-left) else: while now+B[i]*(i+1-left)>H: now-=ruisekiwa[i]-ruisekiwa[left] score-=A[left] left+=1 if now+B[i]*(i+1-left)<=H: score+=A[i] now+=B[i]*(i+1-left) ans=max(ans,score) print(ans)