#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e6 + 10;
int t, n, m, k, l, r, op, x, y;
int f[N];
void solve() {
vector<int> ans;
while (cin >> n) {
ans.clear();
do {
ans.push_back(n % 8);
n /= 8;
} while (n);
reverse(ans.begin(), ans.end());
for (int num : ans) {
cout << num;
}
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}