HUST 2016招新选拔

From: 2016-03-06 14:00:00 To: 2016-03-06 17:30:00 Now: 2017-09-24 21:44:30 Status: Public

E - Digit Problem

Time Limit: 1s Memory Limit: 512MB

Submissions: 12 Solved: 4
Description

Keqiang was interested in integers with equal sum of digits these days. He asked Jinping to find n positive integers with equal sum of digits. The requirement is minimal these integers’ total sum. Jinping was tired now and ask for you to handle this problem.

Input

The input contains a line with a single integer n (1 <= n <= 5000)

Output

Ouput the minimal sum of these n positive integers, these n positive integers have same sum of digits.

Sample Input
3
Sample Output
33
Hint
Source