def roman_figure(c)
  case c
  when "I"
    return 1
  when "V"
    return 5
  when "X"
    return 10
  when "L"
    return 50
  when "C"
    return 100
  when "D"
    return 500
  when "M"
    return 1000
  end
end

while line = gets
  sum = 0
  line.chomp!.each_char do |c|
    sum += roman_figure(c)
  end
  
  print sum
end