#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int binpow(int a, int b) {
    if(b==0) return 1;
    int x=binpow(a,b/2);
    x=(x*x)%mod;
    if(b%2==0) return x;
    else return (x*a)%mod;
}
signed main() {
    int n;
    cin>>n;
    // run l from 1 to 1e7
    int l=1;
    int r=1;
    int cur=1;
    int ans=0;
    while(l<1e7) {
        if(cur==n) {
            //cout<<l<<" "<<r<<endl;
            ans=(ans+1)%mod;
        }
        if(cur<=n) {
            r++;
            cur+=(int)log10(r)+1; // digit of r
        }
        if(cur>n) {
            l++;
            cur-=((int)log10(l-1)+1);
        }
    }
    //cout<<"ans = "<<ans<<endl;
    for(int dig=8 ; dig<=n ; dig++) {
        if(n%dig==0) {
            // can use all dig-digit numbers
            int cnt=n/dig;
            int up=binpow(10,dig);
            int down=binpow(10,dig-1);
            int add=(up-cnt+1)-down;
            //cout<<"digit = "<<dig<<endl;
            //cout<<"add = "<<add<<endl;
            ans=(ans+add+mod)%mod;
        }
        // dig*a+(dig+1)*b=n
        // => (dig)(a+b)=n-b
        // b%(dig)==(n)%(dig)
        int rem=(n%dig);
        if(!rem) rem=dig;
        int low=rem*(dig+1);
        int hi=dig*(dig+1); // n>dig*a because b must >0
        if(low<n) ans=(ans+(n-low-1)/hi+1)%mod;
    }
    cout<<ans;
}