#include <cstdio>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

typedef long long ll;
const int N = 23000000;
const int mod = 1e9 + 7;

ll ans;
int dig[N + 10], po[10];
int S, sum, r;

ll pow(ll x, ll y, int mod)
{
    ll ans = 1;
    for(; y; y >>= 1)
    {
        if (y & 1) ans = ans * x % mod;
         x = x * x % mod;
    }
    return ans;
}

ll work(int x)
{
    int tmp = S / x;
    return (pow(10LL, tmp - 1, mod) * 9 - x + 1 + mod) % mod;
}

int main()
{
    scanf("%d", &S);
    po[0] = 1; FOR(i, 1, 7) po[i] = po[i - 1] * 10;
    FOR(i, 0, 7) dig[po[i]] = 1;
    FOR(i, 1, N) dig[i] += dig[i - 1];
    FOR(i, 1, po[7] - 1)
    {
        sum -= dig[i - 1];
        while (sum + dig[r + 1] <= S) sum += dig[++r];
        if (sum == S) ++ans;
    }
    int tmp = S / 8;
    FOR(i, 1, tmp)
        if (S % i == 0) (ans += work(i)) %= mod; else ++ans;
    printf("%lld\n", ans % mod);
    return 0;
}
