#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
LL S;
int d[10];

LL pw(LL x , LL y){
	LL res = 1;
	LL z = x;
	for(LL i = y ; i > 0 ; i >>= 1){
		if(i&1) (res *= z) %= mod;
		z = z * z % mod;
	}
	return res;
}

int main(){
	cin >> S;
	LL ans = 0;
	int j = 1;
	int x = 1 , y = 1;
	LL z = 0;
	d[0] = 1;
	repp(i,0,9) d[i+1] = d[i] * 10;
	repp(i,1,1e7){
		if(i == d[x]) ++x;
		while(z < S){
			z += y;
			++j;
			if(j == d[y]) ++y;
		}
		if(z == S) ++ans;
		z -= x;
	}
	for(LL i = 1 ; i * i <= S ; ++i){
		if(S%i) continue;
		if(i >= 8) (ans += 9 * pw(10,i-1) - S/i + 1) %= mod;
		if(S/i >= 8 && i * i < S) (ans += 9 * pw(10,S/i-1) - i + 1) %= mod;
	}
	repp(i,8,S/2+1) (ans += (S-1)/i - (S+i+1)/(i+1) + 1) %= mod;
	if(ans<0) ans += mod;
	cout << ans << endl;
	return 0;
}
