#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
ll mpow(ll x, ll y, ll m) {
    if(y == 0) {
        return 1;
    } else {
        ll z = mpow(x, y / 2, m);
        return z * z % m * (y % 2 ? x % m : 1) % m;
    }
}
const ll MOD = 1000000007;
ll count_digits(ll d) {
    return 9 * mpow(10, d - 1, MOD) % MOD;
}
ll sum_digits(ll d) {
    return d * count_digits(d);
}
ll sum_between(ll min_digits, ll max_digits) {
    ll ans = 0;
    for(ll d = min_digits + 1; d < max_digits; d++) {
        ans += sum_digits(d);
    }
    return ans;
}
ll lcm(ll x, ll y) {
    return x * y / __gcd(x, y);
}
ll ceildiv(ll x, ll y) {
    return (x + y - 1) / y;
}
ll count_multiples_between(ll L, ll R, ll div) {
    return ceildiv(R - L + 1, div);
}
vector<ll> divisors(ll n) {
    vector<ll> ans;
    for(ll d = 1; d * d <= n; d++) {
        if(n % d == 0) {
            ans.push_back(d);
            if(d * d != n) {
                ans.push_back(n / d);
            }
        }
    }
    return ans;
}
void solve(long long S) {
    ll ans = 0;
    for(ll digits = 1; digits <= 7; digits++) {
        if(S % digits == 0 and S / digits <= count_digits(digits)) {
            ans += (count_digits(digits) - S / digits + MOD) % MOD + 1;
            ans %= MOD;
        }
    }
    for(ll min_digits = 1; min_digits <= 8; min_digits++) {
        for(ll max_digits = min_digits + 1; max_digits <= 8; max_digits++) {
            if(S >= sum_between(min_digits, max_digits)) {
                ll remaining = S - sum_between(min_digits, max_digits);
                ll lim_min = sum_digits(min_digits);
                ll lim_max = sum_digits(max_digits);
                if(min_digits + max_digits <= remaining and remaining <= lim_min + lim_max) {
                    ll lb = max(1ll, ceildiv(remaining - lim_min, max_digits));
                    ll ub = min(lim_max / max_digits, (remaining - min_digits) / max_digits);
                    for(ll x = lb, i = 1; x <= ub and i <= min_digits; x++, i++) {
                        // 1 <= x;
                        // x * max_digits <= lim_max, x <= lim_max / max_digits;
                        // 1 <= (remaining - x * max_digits) / min_digits, x <= (remaining - min_digits) / max_digits;
                        // remaining - x * max_digits <= lim_min, (remaining - lim_min) / max_digits <= x;
                        if((remaining - x * max_digits) % min_digits == 0) {
                            ans += count_multiples_between(max(1ll, remaining - ub * max_digits), remaining - x * max_digits, lcm(min_digits, max_digits));
                            ans %= MOD;
                            break;
                        }
                    }
                }
            }
        }
    }
    ans += S / 8;
    ans %= MOD;
    for(ll d : divisors(S)) {
        if(d >= 8) {
            ans += count_digits(d) - S / d + MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}
int main() {
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 256