import sys, math sys.setrecursionlimit(10**8) sys.set_int_max_str_digits(0) INF = 1e18 MOD = 998244353 from bisect import bisect_left, bisect_right from collections import deque, defaultdict, Counter from itertools import product, combinations, permutations, groupby, accumulate from heapq import heapify, heappop, heappush input = sys.stdin.readline def I(): return input().rstrip() def II(): return int(input().rstrip()) def IS(): return input().rstrip().split() def MII(): return map(int, input().rstrip().split()) def LI(): return list(input().rstrip()) def TII(): return tuple(map(int, input().rstrip().split())) def LII(): return list(map(int, input().rstrip().split())) def LSI(): return list(map(str, input().rstrip().split())) def GMI(): return list(map(lambda x: int(x) - 1, input().rstrip().split())) def kiriage(a, b): return (a+b-1)//b N, H = MII() A = LII() B = LII() rB = list(accumulate(B, initial=0)) que = deque() L = 0 ans = 0 satisfaction = 0 fatigue = 0 for i in range(N): a, b = A[i], B[i] # とりあえず append する que.append(i) fatigue += (L + 1)*b L += 1 satisfaction += a # H以下になるように調整 while fatigue > H: l = que[0] r = que[-1] fatigue -= rB[r + 1] - rB[l] satisfaction -= A[l] que.popleft() L -= 1 # i追加時の最善状態にできた #print(i, que) if satisfaction > ans: ans = satisfaction print(ans)