#K48607. Roman Numeral to Integer Conversion

    ID: 28458 Type: Default 1000ms 256MiB

Roman Numeral to Integer Conversion

Roman Numeral to Integer Conversion

In this problem, you are given a Roman numeral in the range from 1 to 3999. Your task is to convert the Roman numeral into its corresponding integer value. The Roman numeral system is based on seven symbols:

  • $$I = 1$$
  • $$V = 5$$
  • $$X = 10$$
  • $$L = 50$$
  • $$C = 100$$
  • $$D = 500$$
  • $$M = 1000$$

When a smaller numeral appears before a larger numeral, it is subtracted. For example, IV is 4 and IX is 9. Otherwise, the values are added together. For example, III is 3 and LVIII is 58.

Read the Roman numeral from standard input and output the corresponding integer to standard output.

inputFormat

The input consists of a single line that contains a valid Roman numeral string. The numeral is guaranteed to represent an integer between 1 and 3999.

outputFormat

Output a single integer, which is the integer representation of the input Roman numeral.

## sample
III
3

</p>