#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

namespace my
{
	//-----------------------------------------------------------------------------
	inline char cn()
	{
		static char buf[1000010],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
	}
	#define cn getchar
	template<class TY>void read(TY &x)
	{
		x=0;int f1=1;char ch=cn();
		while(ch<'0'||ch>'9'){if(ch=='-')f1=-1;ch=cn();}
		while(ch>='0'&&ch<='9')x=x*10+(ch-'0'),ch=cn(); x*=f1;
	}
	char OP[1000030],Zhan[30];int op=0,Top;
	void fcheck(int type=0){if(type||op>=1000000)fwrite(OP,1,op,stdout),op=0;}
	template<class TY>inline void write(TY x)
	{
		if(x==0){OP[op++]='0';fcheck();return;}
		Top=0;while(x)Zhan[++Top]=x%10+'0',x/=10;
		while(Top)OP[op++]=Zhan[Top--];fcheck();
	}
	#define K_G OP[op++]=' '
	//----------------------------快读快输 ----------------------------------------
	
	//--------------------------------------------------------------------------------------------
	#define ll long long
	#define uint unsigned int
	#define ull unsigned long long
	#define INV(x) ksm(x,mod-2)
	const int maxn=100010,inf=1000000007;
	int mod=1000000007;
	void add(ll &x,ll y){x=(x+y>=mod?x+y-mod:x+y);}
	int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
	int fac[maxn],inv_fac[maxn],inv[maxn];
	void work_math()//阶乘
	{
		inv[1]=1;for(int i=2;i<=maxn-10;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[0]=inv_fac[0]=1;for(int i=1;i<=maxn-10;i++)fac[i]=1ll*fac[i-1]*i%mod;
		inv_fac[maxn-10]=INV(fac[maxn-10]);
		for(int i=maxn-11;i>=1;i--)inv_fac[i]=1ll*inv_fac[i+1]*(i+1)%mod;
	}
	struct disc{int x,y;};
	bool compp(disc x,disc y){return x.x<y.x;}
	void discretization(int *darr,int dn)//离散化 
	{
		static disc b[maxn];
		for(int i=1;i<=dn;i++)
		b[i].x=darr[i],b[i].y=i;
		sort(b+1,b+dn+1,compp);
		static int tot=0;b[0].x=-9666;
		for(int i=1;i<=dn;i++)
		if(b[i].x!=b[i-1].x)darr[b[i].y]=++tot;
		else darr[b[i].y]=tot;
	}
	template<class TY>TY gcd(TY x,TY y){return !y?x:gcd(y,x%y);}
	//----------------------------------------------板子---------------------------------------------
	
	//----------------------------------------------------------------------------------------------- 
	#define int long long
	int S,ans=0,ten[maxn];
	int sum(int x,int y){return ten[y]-ten[x-1];}
	
	void main()
	{
		read(S);
		ten[0]=1;for(int i=1;i<=9;i++)ten[i]=ten[i-1]*10;
		for(int i=1;i*i<=S;i++)if(S%i==0)
		{
			#define solve(ln) if((ln)>=9||S/(ln)<=sum(ln,ln))add(ans,ksm(10,ln-1)*9ll%mod-S/(ln)+1+mod)
			solve(i);if(i*i!=S)solve(S/i);
		}
		for(int i=1;i<=8;i++)
		{
			ll Sum=0;
			for(int j=i+2;j<=8;j++)
			{
				Sum+=sum(j-1,j-1)*(j-1);if(Sum>=S)break;
				int limit=sum(i,i),J=sum(j,j);
				for(int k=1;k<=limit;k++)
				{
					int s=S-Sum-k*i;if(s<j)break;
					if(s%j==0&&s/j<=J)add(ans,1);
				}
			}
		}
		for(int i=1;i<=S/2;i++)
		{
			int t=ceil(1.0*(S+1)/(i+1)),a=-S+t*(i+1),b=S-t*i;
			while((i>=9||a<=sum(i,i))&&b>0)
			{
				if(i+1>=9||b<=sum(i+1,i+1))add(ans,1);
				a+=i+1;b-=i;
			}
		}
		printf("%lld",ans);
		fcheck(1);return;
	}
}

signed main(){my::main();return 0;}

Measured memory_bytes: 128