class IterDiffBase {

    public static void baseSevenPrint(int n) {
        Integer N;
        MyStack<Integer> sta = new MyStack<Integer>();
        while (n >=7) {
	    sta.push(n);
            n = n/7;
	}
        System.out.print(n % 7);
        boolean stackNotEmpty = true;

        while(stackNotEmpty) {
	    N = sta.pop();
            if (N == null) {stackNotEmpty = false;}
            else {System.out.print(N % 7);}
        }
        
        System.out.print('\n');
    }

    public static void main (String [] args) {
        baseSevenPrint(99);
    }
}


class MyStack<AnyType> {
    AnyType [] arr;
    int StackTop;
    public MyStack() {
        arr = (AnyType []) new Object[20];
        StackTop = -1;
    }

    public void push (AnyType o) {
        StackTop++;
        arr[StackTop] = o;
    }
    public AnyType pop () {
        if (StackTop == -1) {return null;}
        else {
            StackTop--;
            return  (arr[StackTop + 1]);
        }
    }
}

