N, H = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) A_cumsum = [0] * (N + 1) B_cumsum = [0] * (N + 1) B_cumsum_weighted = [0] * (N + 1) for i in range(1, N + 1): A_cumsum[i] = A_cumsum[i - 1] + A[i - 1] B_cumsum[i] = B_cumsum[i - 1] + B[i - 1] B_cumsum_weighted[i] = B_cumsum_weighted[i - 1] + i * B[i - 1] max_satisfaction = 0 L = 1 for R in range(1, N + 1): while L <= R: fatigue = (B_cumsum_weighted[R] - B_cumsum_weighted[L - 1]) - (L - 1) * (B_cumsum[R] - B_cumsum[L - 1]) if fatigue <= H: break L += 1 if L > R: continue satisfaction = A_cumsum[R] - A_cumsum[L - 1] if satisfaction > max_satisfaction: max_satisfaction = satisfaction print(max_satisfaction)