#include<cstring>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int n;
while(1)
{
scanf("%d",&n);
if(n==0)break;

char ans[128];

sprintf(ans,"%o",n);
//printf("%s\n",ans);
for(int i=0;ans[i]!='\0';i++)
{
if(ans[i]>='4')ans[i]++;
if(ans[i]>='6')ans[i]++;
}
printf("%s\n",ans);
}
/*while(true)
{
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
	{
	
	if(i%10==4 || i/10==4)
		{
		//cout<<i<<endl;
		ans+=2;
		
		}
	else if(i%10==6 || i/10==6)
		{
		//cout<<i<<endl;
		ans+=2;
		
		}
	else ans++;

	}
	if(ans%10==4 || ans%10==6)ans++;
cout<<ans<<endl;
}*/
return 0;
}