#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <functional>
#include <map>
#include <cmath>
using namespace std;

int S, dp[25000009], a[25000009], power[5000009], mod = 1000000007;
const int MAX_N = 25000000;

long long modpow(long long p, long long q, long long m) {
	long long r1 = 1, r2 = p;
	for (int i = 0; i < 30; i++) {
		if ((q&(1LL << i)) != 0) { r1 *= r2; r1 %= mod; }
		r2 *= r2; r2 %= mod;
	}
	return r1;
}

long long solve_2(long long n, long long k) {
	if (dp[k] > n) return 0;
	long long L = k, R = MAX_N, M, maxn = -1;
	for (int i = 0; i < 30; i++) {
		M = (L + R) / 2;
		if (dp[M] - dp[M - k] <= n) { maxn = max(maxn, M); L = M; }
		else { R = M; }
	}
	return maxn - (k - 1);
}

long long solve(long long n, long long k) {
	if (dp[MAX_N] - dp[MAX_N - k] <= n) {
		if (n%k == 0) {
			if (n / k <= 5000000) return ((power[n / k] - power[n / k - 1] + mod) - k + 1 + mod) % mod;
			return ((modpow(10, n / k, mod) - modpow(10, n / k - 1, mod) + mod) - k + 1) % mod;
		}
		return 1;
	}
	return solve_2(n, k) - solve_2(n - 1, k);
}

int main() {
	cin >> S;
	power[0] = 1; for (int i = 1; i <= 5000000; i++) power[i] = (1LL * power[i - 1] * 10LL) % mod;
	for (int i = 1; i <= 8; i++) {
		for (int j = power[i - 1]; j < power[i]; j++) {
			if (j > 25000000) break;
			a[j] = i;
		}
	}
	for (int i = 1; i <= 25000000; i++) dp[i] = dp[i - 1] + a[i];

	long long sum = 0;
	for (int i = 1; i <= min(MAX_N, 15000000); i++) {
		sum += solve(S, i); sum %= mod;
	}
	cout << sum << endl;
	return 0;
}