import java.util.Scanner;
// 除基数取余,直到商为0,余数反转
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long sum = 0;
        long count = 0;
        while (true) {
            if (n / 6 == 0) {
                sum += (long)Math.pow(10, count) * (n % 6);
                break;
            }
            sum += (long)Math.pow(10, count) * (n % 6);
            n = n / 6;
            count ++;
        }
        System.out.println(sum);
    }
}