Submit | All submissions | Best solutions | Back to list |
EI2122Q1ADAF2 - Minimum number of moves |
You are given an integer N (0 ≤ N ≤ 107). On each move, you may subtract one of the digits from the number.
What is the minimum number of moves to make the number equal to 0?
Input
- The only integer N.
Output
The minimums number of moves.
Sample
Input |
Output |
18 |
3 |
20 |
4 |
* Hints: 18 -> 18 – 8 = 10 -> 10 – 1 = 9 -> 9 – 9 = 0
20 -> 18 -> 10 -> 9 -> 0