#include<iostream>#include<stack>usingnamespace std;
stack<int> stk;int a[]={6,2,3};//个位数int b[]={2,3,6};//非个位数 longlongqmi(int a,int b){longlong res =1;while(b){if(b &1) res = res * a;
a = a * a;
b >>=1;}return res;}intmain(){// for(int zls=1;zls<100;zls++){int n;// n=zls;
cin>>n;longlong h =0;//三进制中的位数for(int i =1;; i ++){if(n <=3*(qmi(3, i)-1)/2){
h = i;break;}}
stk.push(a[n %3]);for(int i =1; i <= h -1; i ++)//依组减去数量{longlong Sum =qmi(3, i);longlong Quan = n -3*(Sum -1)/2;if(Quan % Sum ==0){
stk.push(b[(Quan / Sum -1)%3]);}else{
stk.push(b[Quan / Sum %3]);}}while(stk.size()){
cout << stk.top();
stk.pop();}
cout<<endl;//}return0;}