F - Number of Digits Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 900

問題文

正の整数 n に対し、f(n)n10 進法での桁数と定めます。

整数 S が与えられます。 正の整数の組 (l, r) (l \leq r) であって、f(l) + f(l + 1) + ... + f(r) = S を満たすものの個数を 10^9 + 7 で割ったあまりを求めてください。

制約

  • 1 \leq S \leq 10^8

入力

入力は以下の形式で標準入力から与えられる。

S

出力

答えを出力せよ。


入力例 1

1

出力例 1

9

条件を満たす (l, r) の組は (1, 1), (2, 2), ..., (9, 9)9 個あります。


入力例 2

2

出力例 2

98

条件を満たす (l, r) の組は (1, 2)(33, 33) など 98 個あります。


入力例 3

123

出力例 3

460191684

入力例 4

36018

出力例 4

966522825

入力例 5

1000

出力例 5

184984484

Score : 900 points

Problem Statement

For a positive integer n, let us define f(n) as the number of digits in base 10.

You are given an integer S. Count the number of the pairs of positive integers (l, r) (l \leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7.

Constraints

  • 1 \leq S \leq 10^8

Input

Input is given from Standard Input in the following format:

S

Output

Print the answer.


Sample Input 1

1

Sample Output 1

9

There are nine pairs (l, r) that satisfies the condition: (1, 1), (2, 2), ..., (9, 9).


Sample Input 2

2

Sample Output 2

98

There are 98 pairs (l, r) that satisfies the condition, such as (1, 2) and (33, 33).


Sample Input 3

123

Sample Output 3

460191684

Sample Input 4

36018

Sample Output 4

966522825

Sample Input 5

1000

Sample Output 5

184984484