#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

ll extgcd(ll a,ll b,ll &x,ll &y){
    int d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;y=0;
    }
    return d;
}
ll gcd(ll  a,ll b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
int dig(ll n){
    int res=0;
    ll m=n;
    while(m){
        res++;m/=10;
    }
    return res;
}
int main(){
    ll s;cin>>s;
    ll ans=0;
    ll r=0,l=0,temp=0;
    while(l<10000000){
        while(temp<s){
            r++;temp+=dig(r);
            if(temp==s) ans++;
        }
        while(temp>=s){
            l++;temp-=dig(l);
            if(temp==s&&l<10000000) ans++;
        }       
    }
    for(int i=1;i*i<=s;i++){
        if(s%i==0){
            int k=i;
            if(k>=8){
            ans=(ans+modpow(10,k-1)*9-s/k)%MOD;
            }
            k=s/k;
            if(k*k==s) continue;
            if(k<8) continue;
            ans=(ans+modpow(10,k-1)*9-s/k)%MOD;
        }
    }
    ans=(ans+s/8)%MOD;
    if(s%8==0) ans--;
    cout<<ans; return 0;
}

