#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 50;
int num;
int arr[maxn];
void convert(int n){
    num = 0;
    do{
        arr[num++] = n % 8;
        n /= 8;
    }while(n > 0);
}
int main(){
    int n;
    while(~scanf("%d", &n)){
        convert(n);
        for(int i = num - 1; i >= 0; i--){
            printf("%d", arr[i]);
        }
        printf("\n");
    }
    return 0;
}