#C7532. Galactic Numeral Conversion

    ID: 51414 Type: Default 1000ms 256MiB

Galactic Numeral Conversion

Galactic Numeral Conversion

In this problem, you are given a string representing a Galactic numeral. The numeral system is analogous to the Roman numeral system, and uses the following symbols:

  • I: 1
  • V: 5
  • X: 10
  • L: 50
  • C: 100
  • D: 500
  • M: 1000

The conversion follows these rules: normally, the value of each symbol is added. However, if a symbol with a lower value appears before one with a higher value then its value is subtracted. For example, \(IV = 4\) and \(MCMXCIV = 1994\). Your task is to implement a function that converts a Galactic numeral string to its corresponding integer.

inputFormat

The input consists of a single line containing a non-empty string that represents a Galactic numeral.

outputFormat

Output a single integer which is the decimal conversion of the given Galactic numeral.

## sample
III
3