#include <stdio.h>

int main() {
    int n;
    while(scanf("%d",&n)!=EOF){
        int temp=n;int len=0;
        int a[10000000];
        while(temp!=0){
            a[len]=temp%8;
            temp/=8;
            len++;
        }
        for(int i=len-1;i>=0;i--){
            printf("%d",a[i]);
        }
        printf("\n");
    }
    return 0;
}