#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int sum[10000005];
const int modo=1000000007;
int power(int x,int y)
{
    if (y==0) return 1;
    int t=power(x,y/2);
    t=(long long)t*t%modo;
    if (y%2==1) t=(long long)t*x%modo;
    return t;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int s;
    scanf("%d",&s);
    int ans=0;
    if (s<=90)
    {
        int i;
        for (i=3;i<=s;i++)
        {
            //9*(10^i-1) > s
            int temp=s;
            s-=(i-1);
            for (;s%i!=0;)
            {
                s-=(i-1);
            }
            s-=i;
            for (;s%(i-1)!=0;)
            {
                s-=i;
            }
            ans+=s/i/(i-1)+1;
            ans%=modo;
            s=temp;
            if (s%i==0)
            {
                ans+=power(10,i-1)*9ll%modo-s/i+1;
                ans%=modo;
            }
        }
        if (s%2==0)
        {
            ans+=90-s/2+1;
        }
        ans+=max(10-s,0);
        ans%=modo;
        if (s>=10)
        {
            ans+=4;
            ans+=s%2;
        }
        else
        {
            ans+=(s-1)/2;
        }
        ans+=modo;
        ans%=modo;
    }
    else
    {
        int i;
        int t=sqrt(s);
        int p=1;
        sum[0]=0;
        for (i=1;i<=7;i++)
        {
            int j;
            for (j=p;j<p*10;j++)
            {
                sum[j]=sum[j-1]+i;
            }
            p*=10;
        }
        int l=0,r=0;
        for (;r<=9999999;)
        {
            if (sum[r]-sum[l]>s)
            {
                l++;
            }
            else if (sum[r]-sum[l]<s)
            {
                r++;
            }
            else
            {
                ans++;
                l++;
                r++;
            }
        }
        if (s%8==0)
        {
            ans+=90000000-s/8+1;
            ans%=modo;
        }
        {
            int p=1000000;
            int sum=8*(s/8);
            int t=s/8;
            for (i=1;i<=7;i++)
            {
                int j;
                for (j=p*10-1;j>=p;j--)
                {
                    sum+=(8-i);
                    if (sum>s)
                    {
                        sum-=8;
                        t--;
                        if (t<=0) break; 
                    }
                    if (sum==s)
                    {
                        ans++;
                        ans%=modo;
                    }
                }
                p/=10;
                if (t<=0) break;
            }
        }
        int temp;
        for (i=9;i<=t;i++)
        {
            //9*(10^i-1) > s
            temp=s;
            s-=(i-1);
            for (;s%i!=0;)
            {
                s-=(i-1);
            }
            s-=i;
            for (;s%(i-1)!=0;)
            {
                s-=i;
            }
            ans+=s/i/(i-1)+1;
            ans%=modo;
            s=temp;
            if (s%i==0)
            {
                ans+=power(10,i-1)*9ll%modo-s/i+1;
                ans%=modo;
            }
        }
        for (i=1;i<=t;i++)
        {
            int k=s/i;
            if (k<=t) continue;
            if (s%k!=0)
            {
                ans++;
                ans%=modo;
            }
            else
            {
                ans+=power(10,k-1)*9ll%modo-i+1;
                ans%=modo;
            }
        }
        ans+=modo;
        ans%=modo;
        {
            i=t+1;
            temp=s;
            s-=(i-1);
            for (;s%i!=0;)
            {
                s-=(i-1);
            }
            s-=i;
            for (;s%(i-1)!=0;)
            {
                s-=i;
            }
            ans+=s/i/(i-1)+1;
            ans%=modo;
        }
    }
    printf("%d\n",ans);
    return 0;
} 


Measured memory_bytes: 39424