#D5974. Roman Figure
Roman Figure
Roman Figure
Counting was a difficult task in ancient Rome. The Arabic numerals 0,1,2,3,…, 9 have not yet been disseminated. Instead, the following symbols were used:
Arabic numerals | Roman numerals | Arabic numerals | Roman numerals | Arabic numerals | Roman numerals |
---|---|---|---|---|---|
1 | I | 11 | XI | 30 | XXX |
I is 1, V is 5, X is 10, L is 50, C is 100, D is 500, M is 1000, see the table above for other examples. Add when a small number follows a large number, that is, on the right side. When the small number is before the large number, that is, to the left, subtract the small number from the large number. There is only one small number in front of the large number that represents the subtraction per subtraction.
Create a program that converts Roman numerals into Arabic numerals (normal numbers) notation (decimal notation) and outputs them. However, the Roman numerals given only follow the above rules (there are more detailed rules for notation of actual Roman numerals, but they do not need to be considered here. For example, is I a V in actual Roman numerals? From X, X only subtracts from L or C, C only subtracts from D or M, and the same Roman numeral does not add more than 4 (or 5).)
Input
Given multiple datasets. Roman numerals (consecutive strings represented by I, V, X, L, C, D, M in half-width uppercase letters) are given to each data set on one line. The length of each Roman numeral string given is 100 or less.
The number of datasets does not exceed 50.
Output
Output Arabic numerals (integers) on one line for each dataset.
Example
Input
IV CCCCLXXXXVIIII CDXCIX
Output
4 499 499
inputFormat
outputFormat
outputs them. However, the Roman numerals given only follow the above rules (there are more detailed rules for notation of actual Roman numerals, but they do not need to be considered here. For example, is I a V in actual Roman numerals? From X, X only subtracts from L or C, C only subtracts from D or M, and the same Roman numeral does not add more than 4 (or 5).)
Input
Given multiple datasets. Roman numerals (consecutive strings represented by I, V, X, L, C, D, M in half-width uppercase letters) are given to each data set on one line. The length of each Roman numeral string given is 100 or less.
The number of datasets does not exceed 50.
Output
Output Arabic numerals (integers) on one line for each dataset.
Example
Input
IV CCCCLXXXXVIIII CDXCIX
Output
4 499 499
样例
IV
CCCCLXXXXVIIII
CDXCIX
4
499
499
</p>