n,h=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) ans=0 r=0 now=0 now2=0 now3=0 cnt=0 for i in range(n): if i==r: r+=1 now+=a[i] now2+=b[i] now3+=b[i] cnt=1 for j in range(r,n): if now2+(cnt+1)*b[j]<=h: now+=a[j] now2+=(cnt+1)*b[j] now3+=b[j] cnt+=1 r+=1 else: break if now2<=h: ans=max(now,ans) now-=a[i] now2-=now3 now3-=b[i] cnt-=1 print(ans)