n, h = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) s = [0] for i in range(n): s.append(s[i] + B[i]) ans = 0 a = 0 b = 0 r = 0 for l in range(n): while r < n and b + (r - l + 1) * B[r] <= h: b += (r - l + 1) * B[r] a += A[r] r += 1 if b <= h: ans = max(ans, a) if l == r: r += 1 else: b -= s[r] - s[l] a -= A[l] print(ans)