#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    while(cin >> n)
    {
        string ans = "";
        while(n != 0)
        {
            int x = n % 8;
            ans += (x + '0');  
            n /= 8;
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }
    return 0;
}