//Create Time: 2018-04-29 11:52:17
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
ll ten[111];
const ll mod=(ll)1e9+7;
bool solve(int x,ll S){
    int l=1;
    while(x>=ten[l+1])++l;
    S-=l*(ten[l+1]-x);
    if(S<=0)return 0;
    ++l;
    S-=l*(ten[l+1]-ten[l]);
    if(S<=0)return 0;
    ++l;
    ll t;
    while(S>0){
        t=l*(ten[l+1]-ten[l]);
        if(S>t)S-=t,++l;
        else return S%l==0;
    }
}
int main(){
    ll S;cin>>S;
    OUT(S);
    ten[0]=0;
    ten[1]=1;
    rep(i,2,17)ten[i]=ten[i-1]*10;

    int m=sqrt(S+0.5);
    while((m+1)*(m+1)<=S)++m;
    ll ans=0;
    // f[l]=f[r]
    rep(i,1,m+1){
        ll l,k,tmp;
        if(S%i==0){
            l=i;k=S/l;
            // tmp=ans;
            if(l<12){
                if(k<=9*ten[l]) ans+=(9*ten[l]-k+1)%mod;
            } else ans+=(9*powmod(10,l-1,mod)-k+1)%mod;
            // OUT(l,ans,(ans+mod-tmp)%mod);
        }
        if(S%i==0 && S/i>m){
            l=S/i;k=S/l;
            // tmp=ans;
            if(l<12){
                if(k<=9*ten[l]) ans+=(9*ten[l]-k+1)%mod;
            } else ans+=(9*powmod(10,l-1,mod)-k+1)%mod;
            // OUT(l,ans,(ans+mod-tmp)%mod);
        }
    }
    ans%=mod;
    // OUT(m,ans);

    // f[l]=f[r]-1
    for(ll k=2,nxt;k<S;k=nxt+1){
        ll l=S/k;
        nxt=S/l;
        ll tl=k,tr=nxt;
        if(S%tl==0)++tl;
        if(S%tr==0)--tr;
        if(l<11)chmax(tl,(S-9*ten[l+1]+l-1)/l);
        if(l<11)chmin(tr,(S+9*ten[l])/(l+1));
        if(tl<=tr){
            ans+=tr-tl+1;
            // OUT(k,l,tl,tr);
        }
    }
    ans%=mod;
    // ll tmp=ans;
    // OUT(ans);

    int up=1000000;
    rep(i,1,up){
        if(solve(i,S))++ans;
    }
    ans%=mod;
    if(ans<0)ans+=mod;
    // OUT((ans-tmp+mod)%mod);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384