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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

#define int long long

const int mod = 1000*1000*1000 + 7;

int gcd (int a, int b, int & x, int & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
 
bool find_any_solution (int a, int b, int c, int & x0, int & y0, int & g) {
	g = gcd (abs(a), abs(b), x0, y0);
	if (c % g != 0)
		return false;
	x0 *= c / g;
	y0 *= c / g;
	if (a < 0)   x0 *= -1;
	if (b < 0)   y0 *= -1;
	return true;
}

void shift_solution (int & x, int & y, int a, int b, int cnt) {
	x += cnt * b;
	y -= cnt * a;
}
 
int find_all_solutions (int a, int b, int c, int minx, int maxx, int miny, int maxy) {
	int x, y, g;
	if (! find_any_solution (a, b, c, x, y, g))
		return 0;
	a /= g;  b /= g;
 
	int sign_a = a>0 ? +1 : -1;
	int sign_b = b>0 ? +1 : -1;
 
	shift_solution (x, y, a, b, (minx - x) / b);
	if (x < minx)
		shift_solution (x, y, a, b, sign_b);
	if (x > maxx)
		return 0;
	int lx1 = x;
 
	shift_solution (x, y, a, b, (maxx - x) / b);
	if (x > maxx)
		shift_solution (x, y, a, b, -sign_b);
	int rx1 = x;
 
	shift_solution (x, y, a, b, - (miny - y) / a);
	if (y < miny)
		shift_solution (x, y, a, b, -sign_a);
	if (y > maxy)
		return 0;
	int lx2 = x;
 
	shift_solution (x, y, a, b, - (maxy - y) / a);
	if (y > maxy)
		shift_solution (x, y, a, b, sign_a);
	int rx2 = x;
 
	if (lx2 > rx2)
		swap (lx2, rx2);
	int lx = max (lx1, lx2);
	int rx = min (rx1, rx2);
 
	return max(0LL, (rx - lx) / abs(b) + 1);
}

int result = 0;

int powerMod(int a, int n) {
	int result = 1;
	while (n > 0) {
		if (n % 2) {
			result = (1LL*result*a) % mod;
		}
		a = (1LL*a*a) % mod;
		n /= 2;
	}
	return result;
}

int powerInf(ll a, int n) {
	ll result = 1;
	while (n > 0) {
		if (n % 2) {
			result = 1LL*result*a;
			if (result >= mod) result = mod;
		}
		a *= a;
		if (a >= mod) a = mod;
		n /= 2;
	}
	return result;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int s;
	cin >> s;

	for (int i = 1; i*i <= s; ++i) {
		if (s % i == 0) {
			ll num = 9LL*powerInf(10, i-1);
			if (num >= s/i) {
				result = (result + 9LL*powerMod(10, i-1) - s/i + 1 + mod) % mod;
			}
			if (s/i!=i) {
				num = 9LL*powerInf(10, s/i-1);
				if (num >= i) {
					result = (result + 9LL*powerMod(10, s/i-1) - i + 1 + mod) % mod;
				}
			}
		}
	}

	ll num = 9;
	ll md = 9;

	for (int i = 1; i*i <= s; ++i) {
		num *= 10;
		if (num >= mod) num = mod;
		result = (result + find_all_solutions(i, i+1, s, 1, min(s, md), 1, min(s, num)));
		md *= 10;
		if (md >= mod) md = mod;
	}

	for (int i = 1; i*i <= s; ++i) {
		int now = s/i;
		int rem = s%i;
		if (!rem) continue;
		if (now*now >= s) ++result;
	}

	result %= mod;

	for (int i = 1; i <= 12; ++i) {
		ll x = 9;
		REP(iter, i-1) x *= 10;
		for (int j = i+2; j <= 12; ++j) {
			ll total = 0;
			for (int w = i + 1; w < j; ++w) {
				ll now = 9;
				REP(x, w-1) now *= 10;
				total += now*w;
			}
			if (total > s) break;
			total = s - total;
			ll y = 9;
			REP(iter, j-1) y *= 10;
			if (x >= mod) x = mod;
			if (y >= mod) y = mod;
			result = (result + find_all_solutions(i, j, total, 1, x, 1, y)) % mod;
		}
	}

	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 256