LogiQuest

158. Sum of All Digits 1..N

HardDigit DP

Print the sum of the digits of all integers from 1 to n.

Input format

A single integer n.

Output format

The total digit sum.

Example 1

Input

12

Output

51

Example 2

Input

1

Output

1

Constraints

1 ≤ n ≤ 10¹⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…