from collections import deque


N, H = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

q = deque()
ans = 0

fatigue = 0
cum = 0
score = 0
for a, b in reversed(list(zip(A, B))):
    score += a
    cum += b
    fatigue += cum
    q.appendleft((a, b))
    while fatigue > H:
        aprev, bprev = q.pop()
        score -= aprev
        cum -= bprev
        fatigue -= bprev * (len(q) + 1)
    ans = max(ans, score)
print(ans)