class Solution:
    def intToRoman(self, num):
        """
        :type num: int
        :rtype: str
        """
        #1000
        n=len(str(num))
        str1=""
        number_1000=number_100=number_10=number_1=0
        if n==4:
            number_1000=int(num/1000)
            str1+="M"*number_1000
        if n>=3:
            number_100=int((num-1000*number_1000)/100)
            if number_100==9:
                str1+="CM"
            elif number_100>=5:
                str1+="D"
                str1+="C"*(number_100-5)
            elif number_100==4:
                str1+="CD"
            else:
                str1+="C"*number_100
        if n>=2:
            number_10 = int((num - 1000 * number_1000-100*number_100) / 10)
            if number_10==9:
                str1+="XC"
            elif number_10>=5:
                str1+="L"
                str1+="X"*(number_10-5)
            elif number_10==4:
                str1+="XL"
            else:
                str1+="X"*number_10
        number_1=num - 1000 * number_1000-100*number_100-10*number_10
        if number_1 == 9:
            str1 += "IX"
        elif number_1 >= 5:
            str1 += "V"
            str1 += "I" * (number_1 - 5)
        elif number_1 == 4:
            str1 += "IV"
        else:
            str1 += "I" * number_1
        return str1
s=Solution()
num=3
print(s.intToRoman(num))