#include <bits/stdc++.h>

using namespace std;

int main(){
	string a_line;
	int a = 10;
	int b = 8;
	while (cin >> a_line){
		vector<int> number;
		
		for (auto item:a_line){
			number.push_back(item-'0');
		}
		
		reverse(number.begin(), number.end());
		
		vector<int> res;
		while (number.size()){
			int r = 0;
			for (int i=number.size()-1; i>=0; i--){
				number[i] = number[i] + a*r;
				r = number[i] % b;
				number[i] = number[i] / b;
			}
			res.push_back(r);
			while (number.size() && number.back() == 0) number.pop_back();
		}
		reverse(res.begin(), res.end());
		
		for (auto item:res){
			cout << item;
		}
		puts("");
	}
	
	return 0;
}