#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
// powmod p^n%mod
LL powmod(LL p,LL n,LL mod){
	LL q=p%mod;
	LL pow=1;
	while(n){
		if(n&1){
			pow*=q;
			pow%=mod;
		}
		q=q*q;
		q%=mod;
		n/=2;
	}
	return pow;
}
const LL M=1e9+7;
int main() {
	LL S;
	cin >> S;
	if(S==1){
		cout << 9 << endl;
		return 0;
	}
	LL l=1;
	LL dl=1;
	LL bl=10;
	LL r=1;
	LL dr=1;
	LL br=10;
	LL s=1;
	LL ret=0;
	//int debug=0;
	int phase=0;
	while(phase==0){
#if 0
		if(debug>4){
			break;
		}
		debug++;
#endif
		while(s<S){
			r++;
			if(r==br){
				dr++;
				br*=10;
			}
			s+=dr;
		}
		//cerr << r <<  " " << s << endl;
		while(S<=s){
			if(s==S){
				ret++;
			}
			s-=dl;
			l++;
			if(l==bl){
				dl++;
				if(9*bl*dl>=S){
					phase=1;
					break;
				}
				bl*=10;
			}
		}
	}
	//return 0;
	//cerr << ret << " " << r << ", " << l << endl;
	ret%=M;
	//LL k=r-l+1;
	//cerr << S/dl << endl;
	ret+=S/dl;
	ret%=M;
	for(LL k=1;k*k<=S;k++){
		if(S%k==0){
			// 個数がk
			//cerr << S/k << ", " << k << endl;
			if(S/k>=dl){
				ret+=9*powmod(10,S/k-1,M)%M+M-k;
			}
			// 桁数がk
			if(k*k<S&&k>=dl){
				//cerr << k << ", " << endl;
				ret+=9*powmod(10,k-1,M)%M+M-S/k;
			}
			ret%=M;
		}
	}
	cout << ret << endl;


	return 0;
}

