#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void)
{
int n;
vector<int> arr;
while(cin >> n)
{
arr.clear();
while(n != 0)
{
int temp = n % 8;
arr.push_back(temp);
n /= 8;
}
reverse(arr.begin(), arr.end());
for(vector<int>::iterator it = arr.begin();it != arr.end();it++)
cout << *it;
cout << endl;
}
return 0;
}