//void __(){
//    _(ll,s);
//    ll ans = 0;
//    ll p10 = 9;
//    for(ll i = 1; i*i <= s; ++i){
//        if(s%i == 0){
//            ll got = 9*ipow(10,i-1,MOD);
//            if(i >= 9 || got >= s/i)
//                ans += (got-s/i+1+MOD)%MOD;
//            if(i*i < s){
//                ll got = 9*ipow(10,s/i-1,MOD);
//                if(s/i > 9 || got >= i)
//                    ans += (got-i+1+MOD)%MOD;
//            }
//        }
//    }
//    {
//        rep(digits,1,min(s,10ll)){
//            ll lim = min(p10,s/digits);
//            if(p10 <= s)
//                p10 *= 10;
//            rep(first_batch,1,lim){
//                int remaining = s-digits*first_batch;
//                if(remaining == 0) continue;
//                int nxt_dig = digits+1;
//                ll tmp = p10;
//                while(nxt_dig*tmp <= remaining){
//                    remaining -= nxt_dig*tmp;
//                    tmp *= 10;
//                    ++nxt_dig;
//                }
//                if(remaining % nxt_dig == 0){
//                    ++ans;
//                }
//            }
//        }
//    }
//    {
//        ll c1 = 1e8, c2 = 1e8;
//        rep(digits,11,s){
//            while(c1*digits > s-1)
//                --c1;
//            while(c2*(digits+1) > s)
//                --c2;
//            ans += (c1+s-c2*(digits+1))/(digits+1);
//        }
//    }
//    ans = (ans%MOD+MOD)%MOD;
//    print ans;
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
ll ipow(ll x, ll p, ll mod = MOD){
    if(abs(x) >= mod)
        x %= mod;
    if(x < 0)
        x += mod;
    if(p == 0)
        return 1;
    if(p == 1)
        return x;
    return ipow(x * x % mod, p / 2, mod) * ipow(x, p % 2, mod) % mod;
}
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }
    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
void __(){
    _(ll,s);
    ll ans = 0;
    ll p10 = 9;
    for(ll i = 1; i*i <= s; ++i){
        if(s%i == 0){
            ll got = 9*ipow(10,i-1,MOD);
            if(i >= 9 || got >= s/i)
                ans += (got-s/i+1+MOD)%MOD;
            if(i*i < s){
                ll got = 9*ipow(10,s/i-1,MOD);
                if(s/i > 9 || got >= i)
                    ans += (got-i+1+MOD)%MOD;
            }
        }
    }
    {
        rep(digits,1,min(s,10ll)){
            ll lim = min(p10,s/digits);
            if(p10 <= s)
                p10 *= 10;
            rep(first_batch,1,lim){
                int remaining = s-digits*first_batch;
                if(remaining == 0) continue;
                int nxt_dig = digits+1;
                ll tmp = p10;
                while(nxt_dig*tmp <= remaining){
                    remaining -= nxt_dig*tmp;
                    tmp *= 10;
                    ++nxt_dig;
                }
                if(remaining % nxt_dig == 0){
                    ++ans;
                }
            }
        }
    }
    {
        ll c1 = 1e8, c2 = 1e8;
        rep(digits,11,s){
            while(c1*digits > s-1)
                --c1;
            while(c2*(digits+1) > s)
                --c2;
            ans += (c1+s-c2*(digits+1))/(digits+1);
        }
    }
    ans = (ans%MOD+MOD)%MOD;
    print ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}


Measured memory_bytes: 256