#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define bitcount(b) __builtin_popcount(b) typedef long long ll; constexpr int CombMax = 1000; ll comb[CombMax+1][CombMax+1]; int const MOD = 1e9+7; int N; int main() { rep(i, CombMax) comb[i][0] = comb[i][i] = 1; REP(i, 1, CombMax) REP(j, 1, i+1) { comb[i][j] = comb[i-1][j-1]; comb[i][j] += comb[i-1][j]; comb[i][j] %= MOD; } cin >> N; int D = -1; REP(digit, 2, 1145141919810893) { ll sum = 0; rep(i, digit) { if((digit - i) % 3) { continue; } sum += comb[digit-1][i]; } if(sum < N) { N -= sum; } else { D = digit; break; } } for(int S=1; S<(1<=0; i--) { cout << ((S >> i & 1) ? '5' : '3'); } cout << endl; return 0; } } assert(0); }