from collections import deque mod=998244353 from sys import stdin, setrecursionlimit input = stdin.readline readline = stdin.readline import math N,H=map(int, stdin.readline().split()) A=list(map(int, input().split())) B=list(map(int, input().split())) B.append(10**10) AA=[0] for a in A: AA.append(AA[-1]+a) BB=[0];C=[0] for i in range(N+1): BB.append(BB[-1]+(i+1)*B[i]) C.append(C[-1]+B[i]) # print(AA) # print(BB) # print(C) if min(B)>H: print(0) exit() ans=0 for i in range(N): l,r=i,N+1 if B[i]>H: continue while abs(l-r)>1: mid=(l+r)//2 c=BB[mid]-BB[i] cc=C[mid]-C[i] d=c-cc*i if d<=H: l=mid else: r=mid e=AA[l]-AA[i] ans=max(ans,e) print(ans)