N, H = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) right, ans, SUM, satisfaction, sumB = 0, 0, 0, 0, 0 for left in range(N): while right < N and SUM+(right-left+1)*B[right] <= H: SUM += (right-left+1)*B[right] sumB += B[right] satisfaction += A[right] right += 1 ans = max(ans, satisfaction) if left == right: right += 1 continue SUM -= sumB sumB -= B[left] satisfaction -= A[left] print(ans)