//正常写法
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    while (cin >> n) {
        vector<int> result;
        while (n) {
            result.push_back(n % 8);
            n /= 8;
        }
        for_each(result.rbegin(), result.rend(), [](int x) { cout << x; });
        cout << endl;
    }
    return 0;
}
//偷懒写法
//C语言版代码
#include <stdio.h>
int main() {
    int n;
    while (scanf("%d", &n) != EOF) printf("%o\n", n);
    return 0;
}
//C++版代码
#include <iostream>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    while (cin >> n) cout << oct << n << endl;
    return 0;
}
//Java版代码
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            System.out.println(Integer.toOctalString(n));
		  //System.out.printf("%o\n", n);
		  //System.out.println(Integer.toString(n, 8));
        }
    }
}
//Python版代码
while True:
    try:
        print(oct(int(input()))[2:])
    except:
        break