#include #include using namespace std; long long n, num = 0, ans = 0, box = 0, b2 = 0; int main(){ cin >> n; while (n >= pow(7, num)){ num++; } for (int i = num; i >= 0; i--){ box = pow(7, i); b2 = n / box; if (n >= box){ ans += b2 * pow(10, i); } n = n % box; } cout << ans << endl; return 0; }