Morse Index Theorem for Geodesic Segments