영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
At Tumba paper mill — which is responsible for producing banknotes — the printing press has broken down: it can now only print the digit ”1”. Buying a new printing press costs N Swedish kronor, but unfortunately, the paper mill has completely run out of money. However, since they themselves print banknotes, why not print new money so they can buy the new machine?
Because the broken printing press can only print the digit ”1”, they can only print banknotes with the denominations of 1 krona, 11 kronor, 111 kronor, 1111 kronor, and so on.
The paper mill now wonders how many banknotes they need to print to be able to pay for the new printing press. They want to be able to pay with exact money, i.e., exactly N kronor (it is immoral to print more money than they need), and therefore they want to print as few banknotes as possible. Write a program that calculates the number of banknotes they must print.
Input
The first and only line contains an integer N (1 ≤ N ≤ 10^9), the cost in kronor for the new printing press.
Output
Print an integer: the minimum number of banknotes that need to be printed.
Points
Your solution will be tested on several test case groups. To get the points for a group, it must pass all the test cases in the group.
| Group | Point value | Constraints |
|---|---|---|
| 1 | 20 | N ≤ 1000 |
| 2 | 40 | N ≤ 10^6 |
| 3 | 40 | No additional constraints. |
Explanation of samples
- In the first example case, one can use one 1-krona banknote and two 11-kronor banknotes.
- In the second example case, one can use one of each 1-, 11-, 111-, 1111-, and 11111-krona banknote.
예제
예제 1
23
3
예제 2
12345
5
예제 3
282828
28