#K57992. Roman Numeral to Integer

    ID: 30543 Type: Default 1000ms 256MiB

Roman Numeral to Integer

Roman Numeral to Integer

Given a Roman numeral string representing a number in the range \(1\) to \(3999\), convert it to its integer value. The string will consist of the characters I, V, X, L, C, D, and M representing the values \(1, 5, 10, 50, 100, 500,\) and \(1000\) respectively. In a Roman numeral, when a smaller numeral appears before a larger numeral, it is subtracted from the larger numeral. For example, \(IV = 4\) and \(IX = 9\). Your task is to implement a program that reads a Roman numeral from standard input and outputs its corresponding integer value to standard output.

inputFormat

The input consists of a single line containing a valid Roman numeral string in the range from \(1\) to \(3999\).

outputFormat

Output a single integer which is the numeric value of the given Roman numeral.

## sample
III
3

</p>