from itertools import accumulate N, H = map(int, input().split()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] A_wa = [0] + [*accumulate(A)] B_wa = [0] + [*accumulate(B)] r = 0 cost = 0 cands = [] for l in range(N+1): if r < l: r = l cost = 0 while r < N and cost + (r-l+1) * B[r] <= H: cost += (r-l+1) * B[r] r += 1 cands.append(A_wa[r] - A_wa[l]) cost -= (B_wa[r] - B_wa[l]) print(max(cands))