#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 22500000
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int f[maxn+5];
void init()
{
	int l=1,r=10;
	for(int i=1;i<=7;i++)
	{
		for(int j=l;j<=r-1;j++)
			f[j]=i;
		l*=10; r*=10;
	}
	for(int i=l;i<=maxn;i++)
		f[i]=8;
}
ll s;
ll solve1()
{
	int l=1,r=0;
	ll res=0,now=0;
	while(l<10000000)
	{
		while(r<maxn &&  now<s)
			r++,now+=f[r];
		if(now==s)
			(res=(res+1)%mod);
		now-=f[l];
		l++;
	}
//	cerr<<res<<endl;
	return res;
}
ll quickpow(ll p,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
			ans=(ans*p)%mod;
		p=(p*p)%mod;
		k>>=1;
	}
	return ans;
}
ll solve2()
{
	ll maxx=s/8,res=maxx;
	for(int i=1;i<=maxx;i++)
	{
		if(s%i==0)
		{
			int len=s/i;
			ll temp=9ll*quickpow(10,len-1)%mod;
			temp=(temp+mod-i)%mod;
			res=(res+temp)%mod;
		}
	}
	return res;
}
int main()
{
	init();
	scanf("%lld",&s);
	printf("%lld\n",(solve1()+solve2())%mod);
}
