#include #include using namespace std; typedef long long LL; const int N = 21; int n; LL pw[N]; string s; int main() { // freopen("base7.in", "r", stdin); // freopen("base7.out", "w", stdout); scanf("%d", &n); if (n == 0) { puts("0"); return 0; } pw[0] = 1LL; for (int i = 1; i < N; ++i) pw[i] = pw[i - 1] * 7; bool ok = false; for (int i = N - 1; i >= 0; --i) { if (ok) { s += n / pw[i] + '0'; n %= pw[i]; } else { if (n >= pw[i]) { ok = true; s += n / pw[i] + '0'; n %= pw[i]; } } } cout << s << endl; return 0; }