import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n,h = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) r = 0 now = 0 tot = 0 x = 0 ans = 0 for l in range(n): while r < n and now+(r-l+1)*b[r] <=h: now += (r-l+1)*b[r] tot += b[r] x += a[r] r += 1 ans = max(ans, x) now -= tot x -= a[l] tot -= b[l] print(ans)