public class ToBase8 {
    public static void main(String[] args) {
        for (String str : args) {
            int nb = Integer.parseInt(str, 8);
            System.out.println(Integer.toHexString(nb).toUpperCase());
        }
    }
}