Printing Types

Time limit2sMemory limit128 MB

Summary
Count the total number of digits used to write all integers from 1 to N, given modulo 1,234,567.
Level

Medium4 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Suppose you write every natural number from 1 through N. Each digit needed to write a number counts as one printing type.

For N = 10, you write 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10, so 11 printing types are needed in total.

Find the number of printing types needed to write all natural numbers not greater than N.

Input

The first line contains a natural number N.

  • 1 <= N <= 2,000,000,000

Output

Print the number of required printing types modulo 1,234,567.

Examples1

  1. Example 1

    Input
    10
    
    Expected output
    11