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

const ll mod = 1e9+7;

ll n, ans, ten[15] = {1}, sum[15];

ll calc (ll X) {
	if(X <= 10) return ten[X] % mod;
	ll R = calc(X/2);
	R = R * R % mod;
	if(X&1) R = R * 10 % mod;
	return R;
}

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=16;i++) {
		ten[i] = ten[i-1] * 10;
	}
	for(ll i=1;i<=n;i++) {
		ll X = n/i, Y = n%i;
		if(X < 10 && i >= ten[X+1]) break;
		if(X < 10 && (i-Y > ten[X]-ten[X-1] || Y > ten[X+1]-ten[X])) continue;
		if(Y) ans = (ans + 1) % mod;
		else ans = (ans + calc(X) + mod - calc(X-1) + 1 + mod - i) % mod;
	}
	for(ll i=2;i<10;i++) {
		sum[i] = (ten[i] - ten[i-1]) * i;
	}
	for(ll i=2;;i++) {
		if(sum[i] > n) break;
		ll X;
		for(ll j=1;j<=ten[i-1]-ten[i-2];j++) {
			X = j * (i-1);
			for(ll k=i;;k++) {
				X += sum[k];
				if(X >= n) break;
				if((n-X)%(k+1)==0 && (n-X)/(k+1) <= ten[k+1]-ten[k]) ans++;
			}
		}
		ans %= mod;
	}
	printf("%lld\n",ans);
}
