#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<int mod>
struct Mod_Int{
    ll x;

    Mod_Int() : x(0) {}

    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    Mod_Int &operator += (const Mod_Int &p){
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p){
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p){
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p){
        *this *= p.inverse();
        return *this;
    }

    Mod_Int &operator ++ () {return *this += Mod_Int(1);}

    Mod_Int operator ++ (int){
        Mod_Int tmp = *this;
        ++*this;
        return tmp;
    }

    Mod_Int &operator -- () {return *this -= Mod_Int(1);}

    Mod_Int operator -- (int){
        Mod_Int tmp = *this;
        --*this;
        return tmp;
    }

    Mod_Int operator - () const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int inverse() const {
        assert(*this != Mod_Int(0));
        return pow(mod-2);
    }

    Mod_Int pow(ll k) const{
        Mod_Int now = *this, ret = 1;
        while(k){
            if(k&1) ret *= now;
            now *= now, k >>= 1;
        }
        return ret;
    }

    friend ostream &operator << (ostream &os, const Mod_Int &p){
        return os << p.x;
    }

    friend istream &operator >> (istream &is, Mod_Int &p){
        ll a;
        is >> a;
        p = Mod_Int<mod>(a);
        return is;
    }
};

using mint = Mod_Int<MOD>;

template<typename T>
struct Prime{
    Prime() {}

    vector<T> divisors(const T &n) const{
        vector<T> ret;
        for(T i = 1; i*i <= n; i++){
            if(n%i == 0){
                ret.pb(i);
                if(i*i != n) ret.pb(n/i);
            }
        }
        //sort(all(ret));
        return ret;
    }

    vector<pair<T, int>> prime_factor(T n) const{
        vector<pair<T, int>> ret;
        for(T i = 2; i*i <= n; i++){
            int cnt = 0;
            while(n%i == 0) cnt++, n /= i;
            if(cnt > 0) ret.eb(i, cnt);
        }
        if(n > 1) ret.eb(n, 1);
        return ret;
    }

    bool is_prime(const T &n) const{
        if(n == 1) return false;
        for(T i = 2; i*i <= n; i++){
            if(n%i == 0) return false;
        }
        return true;
    }

    vector<bool> Eratosthenes(const int &n) const{
        vector<bool> ret(n+1, true);
        if(n >= 0) ret[0] = false;
        if(n >= 1) ret[1] = false;
        for(int i = 2; i*i <= n; i++){
            if(!ret[i]) continue;
            for(int j = 2; i*j <= n; j++) ret[i*j] = false;
        }
        return ret;
    }
};

int main(){
    int S;
    cin >> S;

    int pw[10];
    pw[0] = 1;
    rep(i, 9) pw[i+1] = pw[i]*10;
    Prime<int> P;
    mint ans = 0, ten = 10;
    vector<int> ds = P.divisors(S);

    for(auto &e: ds){
        int x = S/e;
        if(e <= 9 && pw[e]-pw[e-1] < x) continue;
        ans += ten.pow(e)-ten.pow(e-1)+1-x;
    }

    ans += S/8;
    for(auto &e: ds){
        if(e <= S/8) ans--;
    }

    rep2(i, 1, 8){
        rep2(j, i+1, 8){
            int n = S;
            rep2(k, i+1, j-1){
                n -= k*(pw[k]-pw[k-1]);
            }
            rep2(k, 1, pw[i]-pw[i-1]){
                n -= i;
                if(n <= 0) break;
                if(n%j == 0 && n/j <= pw[j]-pw[j-1]) ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632