#K55837. Roman Numeral to Integer Conversion

    ID: 30064 Type: Default 1000ms 256MiB

Roman Numeral to Integer Conversion

Roman Numeral to Integer Conversion

Given a Roman numeral, convert it to its corresponding integer value. Roman numerals are represented by the following symbols and their respective values:

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

In a Roman numeral, when a smaller numeral appears before a larger numeral, the smaller numeral is subtracted. Otherwise, the numeral is added to the total.

Your task is to read a single line from standard input containing a valid Roman numeral (in the range 1 to 3999) and output its integer value to standard output.

inputFormat

The input consists of one line containing a string that represents a valid Roman numeral. It is guaranteed that the numeral is properly formatted and its integer value is between 1 and 3999.

outputFormat

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

## sample
III
3