n,h=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
g=0
r=0
s1=0
s2=0
s3=0
for l in range(n):
	while r+1<=n and s2+(r+1-l)*b[r]<=h:
		s1+=a[r]
		s2+=(r+1-l)*b[r]
		s3+=b[r]
		r+=1
	g=max(g,s1)
	s1-=a[l]
	s2-=s3
	s3-=b[l]
print(g)