#C1633. Roman Numerals to Integer

    ID: 44860 Type: Default 1000ms 256MiB

Roman Numerals to Integer

Roman Numerals to Integer

This problem requires you to convert a given Roman numeral to its corresponding integer. Roman numerals consist of the symbols I, V, X, L, C, D, and M representing 1, 5, 10, 50, 100, 500, and 1000 respectively.

The numeral is generally read from left to right. However, in cases where a smaller numeral appears before a larger one, it is subtracted rather than added. For instance, the numeral IV represents 4 because 1 is subtracted from 5.

Your task is to implement the conversion algorithm.

inputFormat

A single line of input containing a non-empty string S that represents a valid Roman numeral.

outputFormat

Output a single integer which is the conversion result of the Roman numeral S.## sample

III
3