def max_satisfaction(N, H, A, B): max_satisfaction = 0 current_fatigue = 0 current_satisfaction = 0 left = 0 for right in range(N): current_satisfaction += A[right] current_fatigue += B[right] * (right - left + 1) while current_fatigue > H: current_fatigue -= B[left] * (right - left + 1) left += 1 current_satisfaction -= A[left - 1] max_satisfaction = max(max_satisfaction, current_satisfaction) return max_satisfaction # Input reading import sys input = sys.stdin.read data = input().split() N = int(data[0]) H = int(data[1]) A = list(map(int, data[2:N+2])) B = list(map(int, data[N+2:2*N+2])) result = max_satisfaction(N, H, A, B) print(result)