#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int K = 30000000 - 1;
const ll M = ll(1e9) + 7;

int n, s[K + 1];
ll ans;

ll pw(ll n, ll k){
	if(k == 1) return n;
	return pw(n * n % M, k / 2) * (k % 2 ? n : 1) % M;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for(int i = 1, j = 0, k = 1, t = 0; i <= K; i++){
		for(; k <= i; ){ k *= 10; j++; }
		s[i] = s[i - 1] + j;
		for(; s[i] - s[t + 1] >= n; ) t++;
		if(t >= 9999999) break;
		if(s[i] - s[t] == n) ans++;
	}
	ll t = ll(9e7);
	for(int i = 8; i <= n / 100; i++, t = t * 10 % M){
		if(n % i) continue;
		ans = (ans + t - (n / i) + 1 + M) % M;
	}
	for(int i = 1; i <= 99; i++){
		if(n % i) continue;
		if(n / i < 8) continue;
		ans = (ans + 9 * pw(10, n / i - 1) - i + 1 + M) % M;
	}
	for(int i = 8; i <= n / 2; i++){
		int q = n / i, r = n % i;
		if(q > r){
			ans = (ans + (q - r - 1) / (i + 1) + 1) % M;
			if(!r) ans = (ans + M - 1) % M;
		}
	}
	cout << ans << endl;
}