Write code to convert a string of Roman numerals into an integer (for example, MCMLXII -> 1962).
Implement roman_to_integer(s), which accepts a valid, canonical Roman numeral string and returns its integer value. Handle subtractive pairs such as IV, IX, XL, XC, CD, and CM.
The input represents a value from 1 through 3999 and uses only I, V, X, L, C, D, and M.
def roman_to_integer(s):