def roman(n):
        rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
        int_val = 0
        for i in range(len(n)):
            if i > 0 and rom_val[n[i]] > rom_val[n[i - 1]]:
                int_val += rom_val[n[i]] - 2 * rom_val[n[i - 1]]
            else:
                int_val += rom_val[n[i]]
        return int_val

n=input()
print(roman(n))
