#include #include using namespace std; using namespace atcoder; typedef long long int ll; typedef long double ld; #define FOR(i,l,r) for(ll i=l;i=l;i--) #define RREP(i,n) RFOR(i,0,n) #define ALL(x) x.begin(),x.end() #define PA pair #define F first #define S second #define BS(A,x) binary_search(ALL(A),x) #define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin()) #define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin()) #define COU(A,x) (UB(A,x)-LB(A,x)) #define sz(c) ((ll)(c).size()) //#include //namespace mp=boost::multiprecision; //using Bint=mp::cpp_int; templateusing min_priority_queue=priority_queue,greater>; templatebool chmax(T&a,T b){if(abool chmin(T&a,T b){if(bvoid print(vectorA){REP(i,A.size()){if(i)cout<<" ";cout<Q={1,0,0,0,1,0,1,0,2,1}; vectorten(19,1); ll solve(ll N){ if(!N)return 0; string S=to_string(N); ll M=sz(S),res=0; FOR(i,1,M){ res+=5*ten[i-1]; if(i>1)res+=54*(i-1)*ten[i-2]; } FOR(j,1,S[0]-'0'){ res+=Q[j]*ten[M-1]; res+=ten[M-1]/5*3*(M-1); } N-=ten[M-1]*(S[0]-'0'); res+=Q[S[0]-'0']*(N+1); res+=M-1; FOR(i,1,M-1){ if(ten[i]<=N)res+=(M-1-i)*9*ten[i-1]; else{ res+=(M-1-i)*(N-ten[i-1]+1); break; } } return res+solve(N); } int main(){ REP(i,18)ten[i+1]=ten[i]*10; ll K;cin>>K; ll l=1,r=1e17; while(l!=r){ ll m=(l+r)/2,t=solve(m); if(t>=K)r=m;else l=m+1; } if(solve(l)!=K)l=-1; cout<