#K79552. Roman Numeral to Integer Conversion

    ID: 35333 Type: Default 1000ms 256MiB

Roman Numeral to Integer Conversion

Roman Numeral to Integer Conversion

In this problem, you are given a valid Roman numeral as input. Your task is to convert this Roman numeral into its corresponding integer value.

The Roman numeral system is based on the following symbols:

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

In order to correctly convert the numeral, you should also take into account the subtractive notation. In particular, if a numeral of smaller value appears before a numeral of larger value, the smaller numeral is subtracted. For example: \(IV = 4\) and \(IX = 9\).

Your program should 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 non-empty string representing a valid Roman numeral. The string will only contain the characters I, V, X, L, C, D, and M.

outputFormat

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

## sample
III
3