n,h=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) rui=[0]*(n+1) for i in range(n): rui[i+1]=rui[i]+b[i] right = 0 now_manzoku = 0 now_hirou = 0 ans = 0 for left in range(n): while righth:break now_hirou+=(right-left+1)*b[right] now_manzoku+=a[right] right+=1 if now_hirou>h: right-=1 now_manzoku-=a[right] now_hirou-=(right-left+1)*b[right] break ans=max(ans,now_manzoku) now_manzoku-=a[left] now_hirou-=rui[right]-rui[left] print(ans)