import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) input = sys.stdin.readline #n = int(input()) #alist = list(map(int,input().split())) #alist = [] #s = input() n,h = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = 0 #https://github.com/tsutaj/pastbook-2-source-code/blob/main/python/chapter3/3-2-1.py l, r = 0, 0 fat = 0 temp = 0 res = 0 for l in range(n): while r < n and fat + b[r] * (r-l+1) <= h: fat += b[r] * (r-l+1) temp += b[r] res += a[r] r += 1 ans = max(ans, res) if r - l >= 1: fat -= temp temp -= b[l] res -= a[l] else: r += 1 print(ans)