#K55527. Roman Numerals to Integer Conversion

    ID: 29995 Type: Default 1000ms 256MiB

Roman Numerals to Integer Conversion

Roman Numerals to Integer Conversion

Given a string representing a Roman numeral, convert it to an integer. Roman numeral conversion follows specific rules: each symbol has a fixed integer value and when a symbol of lower value appears before one of higher value, it is subtracted. For example, IV is 4 and MCMXCIV is 1994.

The conversion can be mathematically understood as follows: $$\text{Result} = \sum_{i=1}^{n}{v_i}$$, where each numeral v_i is added or subtracted based on its position relative to larger numerals.

Your task is to write a program that reads a Roman numeral from standard input (stdin) and outputs the corresponding integer to standard output (stdout).

inputFormat

The input consists of a single line containing a valid Roman numeral string. The string is composed solely of the characters I, V, X, L, C, D, and M.

outputFormat

Output a single integer which is the result of converting the given Roman numeral to an integer.

## sample
III
3