#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int S;
	scanf("%d",&S);
	ll ret=0;
	int sum=0,tw=10,start=1;
	int nxt=10;
	int f=1,t=1;
	for(int i=1;i<100000000;i++)
	{
		if(i==nxt)
		{
			nxt*=10;
			t++;
		}
		sum+=t;
		while(sum>S)
		{
			sum-=f;
			start++;
			if(start==tw)
			{
				tw*=10;
				f++;
			}
		}
		if(sum==S) ret++;
	}
	//printf("%lld\n",ret);
	ll all=900000000;
	for(int k=8;k<=S;k++)
	{
		int mx=S/k;
		int t=S%k;
		if(t==0) mx--,t+=k;
		if(mx-t>=0)
		{
			ret+=(mx-t)/(k+1)+1;
			if(ret>=MOD) ret-=MOD;
			if(S%(k+1)==0)
			{
				int len=S/(k+1);
				ret+=all-len;
				if(ret<0) ret+=MOD;
				if(ret>=MOD) ret-=MOD;
			}
		}
		all=all*10LL%MOD;
	}
	printf("%lld\n",ret);
	return 0;
}
