Optimal gap-affine alignment in O(s) space