from collections import deque n, h = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) maxv = 0 q = deque() curr_tired = 0 satisfaction = 0 for i in range(n): q.append((a[i], b[i])) satisfaction += a[i] curr_tired += b[i] tired = sum((j + 1) * item[1] for j, item in enumerate(q)) while tired > h and q: removed = q.popleft() satisfaction -= removed[0] curr_tired -= removed[1] tired = sum((j + 1) * item[1] for j, item in enumerate(q)) maxv = max(maxv, satisfaction) print(maxv)