main = getLine >>= putStrLn . solve . words solve ls = ["I","II","III","IIII","V","VI","VII","VIII","IX","X","XI","XII"] !! (((sum $ map calc (head ls)) + (read (last ls)) + 11) `mod` 12) calc 'I' = 1 calc 'V' = 5 calc 'X' = 10