Old clock towers and movie credits use Roman numerals: I=1, V=5, X=10, L=50, C=100, D=500, M=1000.
Usually symbols are added (VI = 6), but a smaller symbol before a bigger one is subtracted (IV = 4, IX = 9, XL = 40, CM = 900). Convert the Roman numeral to a normal number.
Input Format A single valid Roman numeral in capital letters.
Output Format Print its value.
Constraints • The value is between 1 and 3999.
Examples
Example 1
Input
XIV
Output
14
Explanation X (10) + IV (4) = 14.
Example 2
Input
MCMXCIV
Output
1994
Explanation M (1000) + CM (900) + XC (90) + IV (4) = 1994.
Example 3
Input
III
Output
3
Explanation 1 + 1 + 1 = 3.
Example 4
Input
LVIII
Output
58
Explanation L (50) + V (5) + III (3) = 58.
Acceptance—
Accepted0
Submissions0
Auto-save
SavedLn 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
14
No results yet
Run your code to test it against the sample cases.