#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int pow1(int x,int y)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x);
      x=mult(x,x);
      y>>=1;
    }
  return ans;
}
int s,ans;
void fun(int ind,int done)
{
  if(done>=s) return;
  if(ind==8)
    {
      if(!done) return;
      int rem=s-done;
      ans=add(ans,((rem%8)==0));
      return;
    }
  int tot=mult(9,pow1(10,ind-1));
  if(done)
    {
      //take some
      int rem=s-done;
      ll tmp=(ll)done+(ll)tot*ind;
      if((rem%ind)==0) ans=add(ans,1);
      //take all
      fun(ind+1,tmp);
    }
  else
    {
      rep(i,1,tot+1)
	{
	  if(i*ind>=s) break;
	  fun(ind+1,i*ind);
	}
      fun(ind+1,done);
    }
}
int calc(int x)
{
  int cnt=0;
  while(x) x/=10,cnt++;
  return cnt;
}
const int N=25000000;
int sum[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  cin>>s;
  //fun(1,0);
  rep(i,1,N)
    sum[i]=sum[i-1]+calc(i);
  int i=1,j=1;
  while(i<1e7)
    {
      while(j<N && sum[j]-sum[i-1]<s) j++;
      if(j<N && sum[j]-sum[i-1]==s) ans=add(ans,1);
      i++;
    }
  //rep(i,1,8) if(s%i==0 && mult(9,pow1(10,i-1))>=s/i) ans=add(ans,add(1+mult(9,pow1(10,i-1)),-(s/i)));
  ans=add(ans,s/8);
  int sq=sqrt(s);
  rep(i,1,sq+1)
    {
      if(s%i!=0) continue;
      if(i<=s/8) ans=add(ans,add(mult(9,pow1(10,s/i-1)),-i));
      if(i*i!=s && s/i<=s/8 && i>7) ans=add(ans,add(mult(9,pow1(10,i-1)),-s/i));
    }
  //first take if range belongs to only within same digits
  /*int sq=sqrt(s);
  rep(i,1,sq+1)
    {
      if((s%i)!=0) continue;
      int x=s/i;
      int curr=mult(9,pow1(10,i-1));
      if(i<=7)
	{
	  if(curr>=x) ans=add(ans,curr-x+1);
	}
      else ans=add(ans,add(curr,-(x-1)));
      if(x==i) continue;
      ans=add(ans,add(mult(9,pow1(10,x-1)),-(i-1)));
      }*/
  //look for adjacent, there can;t be more than 2 adjacent if x>8
  /* ax+b(x+1)=S
     so a=(S-b)/x - b, where x is number of digits,
     so b will be of the form k*x+(S%x)
     so a = (S/x + k - (k*x + S%x)), it should be greater than 0,
     so k< (S/x - S%x) / (x-1)*/
  /*rep(i,8,s)
    {
      if(s%i==0)
	{
	  int tmp=s/i;
	  if(tmp%(i+1)==0) ans=add(ans,max(0,-1+tmp/(i+1)));
	  else ans=add(ans,tmp/(i+1));
	}
      else
	{
	  int k=s/i-(s%i);
	  if(k<0) continue;
	  if(k%(i+1)==0) ans=add(ans,k/(i+1));
	  else ans=add(ans,1+k/(i+1));
	}
	}*/
  //for first 7, there can be any number of adjacent
  /*rep(i,1,3e7+2) sum[i]=sum[i-1]+calc(i);
  int j=3e7,i=1;
  while(i<j)
    {
      if(calc(i)==calc(j)) break;
      while(j>i && sum[j]-sum[i-1]>s) j--;
      if(calc(i)==calc(j)) break;
      if(sum[j]-sum[i-1]==s) ans=add(ans,1);
      i++;
      }*/
  //fun(1,0);
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 97920