Equal Digit Sums

No attempts yetTime limit2sMemory limit256 MB

Problem

The digit sum of a positive integer xx is the sum of its decimal digits. For example, 22, 1111, and 2020 all have digit sum 22.

Pick nn distinct positive integers whose digit sums are all equal. Write a program that finds the smallest total the picked numbers can have.

Input

The first line contains an integer nn (1n50001 \le n \le 5000).

Output

Print the minimum possible sum of nn distinct positive integers that all have the same digit sum.