#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll s;cin>>s;
    ll ans=0;
    rep(i,1,7){
        rep(j,i+2,9){
            ll sum=0;
            rep(k,i+1,j){
                sum+=k*9*Pow(10,k-1);
            }
            if(sum>s)continue;
            
            
            
               rep(k,1,9*Pow(10,i-1)+1){
                    ll r=k*i;
                    if(r+sum>s)break;
                    ll t=s-r-sum;
                    if(t%j!=0)continue;
                    t/=j;
                    if(t<=9*Pow(10,j-1)&&t>0)ans++;
                    ans%=mod;
                }
            
            
        }
    }
    ll e=0;
    rep(i,1,s+1){
        ll ns=s-i-(i+1);
        if(ns<0)break;
        ll f=0;
        if(e==0){
            ll ff=i*(9*Pow(10,i-1)-1);
            if(ff>=ns){
                e=1;
            }
            else f=ns-ff;
        }
        ll ss=ns%i;
        f-=(i+1)*ss;
        if(i<9){
            ll rrr=(i+1)*(9*Pow(10,i)-1);
            if(ns>rrr)ns=rrr;
        }
        ns-=(i+1)*ss;
        if(ns<0)continue;
        ll sl,sr;
        if(f<=0)sl=0;
        else{
            sl=f/(i*(i+1));
            if(f%(i*(i+1))!=0)sl++;
        }
        sr=ns/(i*(i+1));
       // if(ss==0&&sl==0)sl=1;
        (ans+=max((ll)0,sr-sl+1))%=mod;
    }
    vector<ll> ww;
    for(ll i=1;i*i<=s;i++){
        if(s%i==0){
            ww.push_back(i);
            if(i*i<s)ww.push_back(s/i);
        }
    }
    rep(i,0,ww.size()){
        ll now=ww[i];
        ll y=s/now;
        ll rr=beki(10,now-1,mod)*9;
        if(now<9&&y>rr)continue;
        rr%=mod;
        (ans+=rr-y+1+mod)%=mod;
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 256