n, h = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) cum = [0] for b in B: cum.append(cum[-1] + b) ans = 0 r = 0 tot = 0 ca = 0 for l in range(n): while r < n: ntot = tot + B[r] * (r - l + 1) if ntot > h: break tot = ntot ca += A[r] r += 1 ans = max(ans, ca) ca -= A[l] tot -= cum[r] - cum[l] print(ans)