#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 15;
const int M = 1e9 + 7;

inline int add(int a, int b)
{
    a += b;
    if (a >= M)
    {
        a -= M;
    }
    if (a < 0)
    {
        a += M;
    }
    return a;
}

inline int mul(int a, int b)
{
    return (a * (ll) b) % M;
}

inline int bin(int a, int n)
{
    int res = 1;
    while (n)
    {
        if (n % 2 == 0)
        {
            a = mul(a, a);
            n /= 2;
        }
        else
        {
            res = mul(res, a);
            n--;
        }
    }
    return res;
}

ll cnt[N];

bool ok(int type, int grab)
{
    if (type >= N)
    {
        return true;
    }
    else
    {
        return grab <= cnt[type];
    }
}

int gcd (int a, int b, int & x, int & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
 
bool find_any_solution (int a, int b, int c, int & x0, int & y0, int & g) {
	g = gcd (abs(a), abs(b), x0, y0);
	if (c % g != 0)
		return false;
	x0 *= c / g;
	y0 *= c / g;
	if (a < 0)   x0 *= -1;
	if (b < 0)   y0 *= -1;
	return true;
}

void shift_solution (int & x, int & y, int a, int b, int cnt) {
	x += cnt * b;
	y -= cnt * a;
}
 
int find_all_solutions (int a, int b, int c, int minx, int maxx, int miny, int maxy) {
	int x, y, g;
	if (! find_any_solution (a, b, c, x, y, g))
		return 0;
	a /= g;  b /= g;
 
	int sign_a = a>0 ? +1 : -1;
	int sign_b = b>0 ? +1 : -1;
 
	shift_solution (x, y, a, b, (minx - x) / b);
	if (x < minx)
		shift_solution (x, y, a, b, sign_b);
	if (x > maxx)
		return 0;
	int lx1 = x;
 
	shift_solution (x, y, a, b, (maxx - x) / b);
	if (x > maxx)
		shift_solution (x, y, a, b, -sign_b);
	int rx1 = x;

    if (lx1 > rx1)
        swap(lx1, rx1);

	shift_solution (x, y, a, b, - (miny - y) / a);
	if (y < miny)
		shift_solution (x, y, a, b, -sign_a);
	if (y > maxy)
		return 0;
	int lx2 = x;
    //cout << lx2 << ' ' << rx2 << '\n'; 
	shift_solution (x, y, a, b, - (maxy - y) / a);
	if (y > maxy)
		shift_solution (x, y, a, b, sign_a);
	int rx2 = x;
 
	if (lx2 > rx2)
		swap (lx2, rx2);
	int lx = max (lx1, lx2);
	int rx = min (rx1, rx2);
    if (lx > rx) return 0;
	return (rx - lx) / abs(b) + 1;
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    cnt[0] = 0;
    cnt[1] = 9;
    for (int i = 2; i < N; i++)
    {
        cnt[i] = cnt[i - 1] * 10;
    }
    int s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i <= s; i++)
    {
        if (s % i == 0)
        {
            if (ok(i, s / i))
            {
                int cnt = s / i - 1;
                int ret = mul(9, bin(10, i - 1));
                ans = add(ans, add(ret, -cnt));
            }
        }
    }
    for (int i = 1; i <= s; i++)
    {
        int k = s / i;
        int b = s % i;
        while (k)
        {
            if (k > b)
            {
                if (b)
                {
                    int a = k - b;
                    if (ok(i, a) && ok(i + 1, b))
                    {
                        ans = add(ans, 1);
                    }
                }
            }
            else
            {
                break;
            }
            k--;
            b += i;
        }
    }
    for (int i = 2; i < N; i++)
    {
        ll cur = 0;
        for (int j = i; j < N; j++)
        {
            cur += j * cnt[j];
            if (cur <= s)
            {
                s -= cur;
                //cout << i - 1 << ' ' << j + 1 << '\n';
                int cr = find_all_solutions(i - 1, j + 1, s, 1, cnt[i - 1], 1, cnt[j + 1]) % M;
                ans = add(ans, cr);
                /*
                int a = i - 1, b = j + 1;
                for (int x = 1; x <= s; x++)
                {
                    for (int y = 1; y <= s; y++)
                    {
                        if (ok(a, x) && ok(b, y) && a * x + b * y == s)
                        {
                            ans = add(ans, 1);
                        }
                    }
                }
                */
                s += cur;
            }
            else
            {
                break;
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256