#include <iostream>
#include <algorithm>
using namespace std;int t;string e(int a){string ret;while(a){t=a%8;t+=(t>4)+(t>3);a/=8;ret+='0'+t;}reverse(ret.begin(),ret.end());return ret;}int main(){while(cin>>t&&t)cout <<e(t)<<endl;}