#include <vector>
#include <iostream>

static const std::vector<int> map{ 0, 1, 2, 3, 5, 7, 8, 9 };
void oct(const int &num) {
	if (num != 0) {
		oct(num / 8);
		std::cout << map.at(num % 8);
	}
}
int main() {
	int n;
	std::cin >> n;
	while (n != 0) {
		oct(n);
		std::cout << "\n";
		std::cin >> n;
	}
}