#include<bits/stdc++.h>
using namespace std;
string conversion(string str,int m,int n)
{
int len = str.length();
int k = 0;
string result = "";
for(int i = 0;i<len;)
{
k = 0;
for(int j = i;j<len;j++)
{
int t = (k*m + str[j]-'0') % n;
str[j] = (k*m + str[j]-'0') / n + '0';
k = t;
}
result += (k+'0');
while(str[i]=='0')i++;
}
return result;
}
string reverse(string str)
{
int len = str.length();
int i = 0;
while(i<len)
{
swap(str[i],str[len-1]);
i++;len--;
}
return str;
}
int main()
{
string str;
while(cin>>str)
{
string result = conversion(str,10,8);
cout<<reverse(result)<<endl;
}
return 0;
}