from collections import deque N, H = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) class D: def __init__(self): self.q = deque() self.a = 0 self.b = 0 self.s = 0 def append(self, a, b): self.s += b * (len(self.q) + 1) self.q.append((a, b)) self.a += a self.b += b def popleft(self): self.s -= self.b a, b = self.q.popleft() self.a -= a self.b -= b def score(self): if self.s > H: return 0 return self.a # a : 入力リスト # pred : 条件 # op : 右端を伸ばす演算 # invop : 左端を縮める演算 def shakutori(a: list, pred, op, invop, identity): n = len(a) res = identity() hi = -1 for lo in range(n): if lo > hi: hi = lo - 1 res = identity() # 必要な分だけ伸ばす while hi+1 < n and pred(res, a[hi+1]): res = op(res, a[hi+1]) hi += 1 if lo <= hi: yield res, lo, hi # lo を一つ進める res = invop(res, a[lo]) # res に x を追加できるか def pred(res: D, x): a, b = x s = res.s + b * (len(res.q) + 1) return s <= H # 伸ばす(res に x を追加) def op(res: D, x): a, b = x res.append(a, b) return res # 縮める(res から x を削除) def invop(res: D, x): if len(res.q) > 0: res.popleft() return res ans = 0 for res, lo, hi in shakutori(list(zip(A, B)), pred, op, invop, D): ans = max(ans, res.score()) print(ans)