#K81092. Roman Numeral to Integer

    ID: 35676 Type: Default 1000ms 256MiB

Roman Numeral to Integer

Roman Numeral to Integer

Given a Roman numeral as a string, convert it to an integer. Roman numerals are represented by the following symbols:

I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, and M = 1000.

In general, when a smaller numeral appears before a larger one, it is subtracted from the total value. Otherwise, it is added. For example, the numeral MCMXCIV is calculated as $$1000 + (1000-100) + (100-10) + (5-1) = 1994$$.

Your task is to implement a program that reads a single Roman numeral from stdin and prints its integer value to stdout.

inputFormat

The input consists of a single line containing a non-empty string representing a valid Roman numeral. The numeral will be in uppercase letters.

outputFormat

Output the integer value corresponding to the Roman numeral given in the input. The result should be printed to stdout.## sample

III
3

</p>