#include #define MOD 1000000007 using namespace std; int main(){ int N; int M=1; cin>>N; while(M*7<=N){ M*=7; } while(M!=0){ cout<