#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
ll sup[10];
void solve() {
	sup[1] = 9;
	Rep1(i, 2, 9) {
		sup[i] = sup[i - 1] * 10;
	}
	int s; cin >> s;
	int k = sqrt(s);
	vector<int> v,u;
	rep1(i, k) {
		if (s%i == 0) {
			if(i>8)v.push_back(i);
			if(s/i>8)v.push_back(s / i);
			u.push_back(i);
			u.push_back(s / i);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	sort(u.begin(), u.end());
	u.erase(unique(u.begin(), u.end()), u.end());
	ll ans = 0;
	//>=9
	//1個
	rep(i, v.size()) {
		ll ran = s / v[i];
		ll num = mod_pow(10, v[i]) - mod_pow(10, v[i] - 1);
		ans += (num - ran + 1);
		ans = (ans%mod + mod) % mod;
	}
	//cout << ans <<" nu"<< endl;
	//2個
	if (s >= 1) {
		ans += s / 9;
		rep(i, u.size()) {
			if (u[i] <= s / 9)ans--;
		}
		ans %= mod;
	}
	//cout << ans <<" hello"<< endl;
	//<9
	//1個
	rep1(i, 8) {
		ll ran = s / i;
		if (s%i)continue;
		if (sup[i] < ran)continue;
		ans += sup[i] - ran + 1; ans %= mod;
	}
	//2個
	rep1(i, 8) {
		/*if (s%i == 0)continue;
		if (s < i)continue;
		ll x = s / i;
		ll a = -s + i * (x + 1);
		ll b = s - i * x;
		if (a > sup[i] || b > sup[i + 1])continue;
		ans++;*/
		ll le = max((ll)s / (i + 1)+1, (s - sup[i + 1] + i - 1) / i);
		ll ri = min((ll)(s + i - 1) / i - 1, (sup[i] + s) / (i + 1));
		ans += max((ll)0, ri - le + 1);
	}
	ans %= mod;
	P le = { 1,0 }; P ri = { 1,0 };
	ll sum = 0;
	while (sum < s) {
		ll ns = sum + ri.first*sup[ri.first];
		if (ns <= s) {
			ri.first++; ri.second = 0; sum = ns;
		}
		else {
			ll dif = s - sum;
			ll d = (dif+ri.first-1) / ri.first;
			ri.second = d; sum += d * ri.first;
			if (ri.second == sup[ri.first]) {
				ri.first++; ri.second = 0;
			}
		}
	}
	//cout << ans << endl;
	while (true) {
		//cout << s << " " << sum << endl;
		while (sum - le.first >= s) {
			sum -= le.first; le.second++;
			if (le.second == sup[le.first]) {
				le.second = 0; le.first++;
			}
		}
		if (ri.first==le.first||(ri.first-le.first==1&&ri.second==0))break;
		if (sum == s) {
			if (ri.first - le.first > 2)ans++;
			else if (ri.first-le.first==2&&ri.second > 0)ans++;
		}
		sum += ri.first; ri.second++;
		if (ri.second == sup[ri.first]) {
			ri.second = 0; ri.first++;
		}
		while (sum-le.first >= s) {
			sum -= le.first; le.second++;
			if (le.second == sup[le.first]) {
				le.second = 0; le.first++;
			}
		}
	}
	cout << ans % mod << endl;
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256