#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const int MAXN=7e6+10;
const int MAXM=505;
const int INF=10000000;
const int mod=1e9+7;
 
ll power(ll a,ll b){
    ll c=1;
    while(b){
        if ((b&1)!=0) c=(c*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return c;
}
 
int f(int a){
    int len=0;
    while(a!=0){
        len++;
        a/=10;
    }
    return len;
}

ll gcd(ll a,ll b){
    if (b==0) return a;
    else return gcd(b,a%b);
}

ll exgcd(ll a,ll b,ll &x,ll &y){
    if (b==0){
        x=1; y=0;
        return a;
    }
    else{
        ll d=exgcd(b,a%b,x,y);
        ll tmp=x;
        x=y;
        y=tmp-(a/b)*y;
        return d;
    }
}

ll num[20],sum[20];
int ch[100][100];

void update(ll &a,ll b){
    a+=b;
    if (a>mod) a-=mod;
    if (a<0) a+=mod;
}

int main(){
    num[1]=sum[1]=9; sum[0]=0;
    for(int i=2;i<=15;i++){
        num[i]=num[i-1]*10;
        sum[i]=sum[i-1]+num[i]*i;
    }    
    ll s;
    scanf("%lld",&s);
    ll cnt1=0;
    for(int i=1;i<=7;i++){
        //ll sss=0;   
        for(int j=i;j<=8;j++){
            //sss+=sum[j];
            if (i==j){
                if (s%i!=0) continue;
                if (num[i]*i<s) continue;
                //update(cnt1,(num[i]-s/i+1)%mod);
                cnt1=(cnt1+num[i]-s/i+1)%mod;
                //cout<<i<<' '<<j<<' '<<num[i]-s/i+1<<endl;
                continue;
            }
            ll c=s;
            c-=(sum[j-1]-sum[i]);
            //for(int k=i+1;k<=j-1;k++){
              //  c-=sum[k];
            //}
            if (c<0 || c>num[j]*j+num[i]*i){
                continue;                
            }
            ll a=i,b=j,d=gcd(a,b);
            if (c%d!=0) continue;
            c/=d; a/=d; b/=d;
            ll x,y;
            exgcd(a,b,x,y);
            ll llim,rlim;
            if ((c*x)%b==0) llim=(-c*x/b+1);
            else llim=(ll)ceil(-1.0*c*x/b);
            //cout<<llim<<endl;
            llim=max(llim,(ll)ceil(1.0*(c*y-num[j])/a));
            //cout<<llim<<endl;
            
            if ((c*y)%a==0) rlim=c*y/a-1;
            else rlim=(ll)floor(1.0*c*y/a);
            //cout<<rlim<<endl;
            rlim=min(rlim,(ll)floor(1.0*(num[i]-c*x)/b));
            
            if (llim>rlim) continue;
            else cnt1=(cnt1+rlim-llim+1)%mod;
            //cout<<i<<' '<<j<<' '<<rlim-llim+1<<endl;
        }
    }

    ll cnt11=0;
    memset(ch,0,sizeof(ch));
    int r=0,sum=0,a=1,len1=1,b=1,len2=1;
    for(int i=1;i<1e7;i++){
        if (i-1<a) sum-=len1-1;
        else a*=10,len1++,sum-=len1-1;
        while(sum<s){
            r++;
            if (r<b) sum+=len2-1;
            else b*=10,len2++,sum+=len2-1;
        }
        if (sum==s){
            //cout<<i<<' '<<r<<endl;
            ch[f(i)][f(r)]++;
            cnt11++;
            if (cnt1==mod) cnt1=0;
        }
    }
    //cout<<cnt1<<endl;
    //for(int i=1;i<=8;i++)
    //    for(int j=i;j<=8;j++)
    //        if (ch[i][j]!=0) cout<<i<<' '<<j<<' '<<ch[i][j]<<endl;
    //cout<<cnt11<<endl;
    ll cnt2=0;
    for(int i=1;(ll)i*(ll)i<=s;i++){
        if (s%i!=0) continue;
        //printf("%d\n",i);
        //printf("%lld\n%lld\n",s,(ll)i*i);
        if (i*8<=s){
            cnt2+=(((power(10,s/i-1)*9)%mod-i)%mod+mod)%mod;
            //update(cnt2,(power(10,s/i-1)*9)%mod);
            //update(cnt2,mod-i);
            cnt2%=mod;
        }
        if (i*i!=s && i>=8){
            cnt2+=(((power(10,i-1)*9)%mod-s/i)%mod+mod)%mod;   
            //update(cnt2,(power(10,i-1)*9)%mod);
            //update(cnt2,mod-s/i);
            cnt2%=mod;
        }

    }
    ll cnt3=s/8;
    cout<<((cnt1+cnt2)%mod+cnt3)%mod<<endl;
    return 0;
}

Measured memory_bytes: 384