import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner a=new Scanner(System.in);
String[][] lm= {
{"","I","II","III","IV","V","VI","VII","VIII","IX"},
{"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
{"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
{"","M","MM","MMM"}
};
int m=a.nextInt();
StringBuffer b=new StringBuffer();
b.append(lm[3][m/1000%10]);
b.append(lm[2][m/100%10]);
b.append(lm[1][m/10%10]);
b.append(lm[0][m%10]);
System.out.println(b);
}
}
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner a=new Scanner(System.in);
String[][] lm= {
{"","I","II","III","IV","V","VI","VII","VIII","IX"},
{"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
{"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
{"","M","MM","MMM"}
};
int m=a.nextInt();
StringBuffer b=new StringBuffer();
b.append(lm[3][m/1000%10]);
b.append(lm[2][m/100%10]);
b.append(lm[1][m/10%10]);
b.append(lm[0][m%10]);
System.out.println(b);
}
}