#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using LL = long long;
LL powers[18];
const int MOD = (int)1e9 + 7;

const int kThreshold = 8;

int power(int a, int b, int p)
{
    int ret = 1;
    for ( ; b; b >>= 1, a = a * 1LL * a % MOD)
        if (b & 1)
            ret = ret * 1LL * a % MOD;
    return ret;
}

inline void add(int &a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
}

int main()
{
    powers[0] = 1;
    for (int i = 1; i < 18; ++ i) powers[i] = powers[i - 1] * 10;
    int S;
    scanf("%d", &S);
    int result = 0;
    int left = 1, right = 0, sum = 0, left_id = 1, right_id = 1;
    for ( ; left < powers[kThreshold - 1]; ++ left) {
        while (sum < S) {
            if (++ right == powers[right_id])
                ++ right_id;
            sum += right_id;
        }
        if (sum == S)
            ++ result;
        if (left == powers[left_id])
            ++ left_id;
        sum -= left_id;
    }
    auto N = [](int d) {
        return ((power(10, d, MOD) - power(10, d - 1, MOD)) % MOD + MOD) % MOD;
    };
    add(result, S / kThreshold);
    for (int t = 1; t <= S / kThreshold; ++ t) if (S % t == 0) {
        add(result, (N(S / t) - t + MOD) % MOD);
    }
    printf("%d\n", result);
}
